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

Error Loading Plugin

Discussion in 'Facepalm' started by Lqchlan, Aug 6, 2017.

  1. Lqchlan

    Lqchlan Creeper

    Messages:
    3
    GitHub:
    Lqchlan
    [14:17:54] [Server thread/ERROR]: Could not load 'E:\PocketMine-MP\plugins\CratePlugin_v1' in folder 'E:\PocketMine-MP\plugins\': Argument 2 passed to pocketmine\permission\Permission::loadPermission() must be of the type array, null given, called in phar://E:/PocketMine-MP/PocketMine-MP.phar/src/pocketmine/permission/Permission.php on line 207
    [14:17:54] [Server thread/CRITICAL]: TypeError: "Argument 2 passed to pocketmine\permission\Permission::loadPermission() must be of the type array, null given, called in phar://E:/PocketMine-MP/PocketMine-MP.phar/src/pocketmine/permission/Permission.php on line 207" (EXCEPTION) in "/src/pocketmine/permission/Permission" at line 223

    any ideas of what ive done wrong?
     
    Last edited by a moderator: Aug 6, 2017
  2. Awzaw

    Awzaw Zombie Pigman Poggit Admin

    Messages:
    726
    GitHub:
    awzaw
    Not without seeing the plugin code.
     
  3. Lqchlan

    Lqchlan Creeper

    Messages:
    3
    GitHub:
    Lqchlan
    <?php

    namespace CratePlugin_v1\CratePlugin_v1:

    use pocketmine\plugin\PluginBase:

    use pocketmine\command\CommandSender:
    use pocketmine\command\Command:\

    use pocketmine\Player:
    use pocketmine\Server:

    use pocketmine\utils\TextFormat as c:

    class Main extends PluginBase{

    }

    public function onEnable(){
    $this->getLogger()->notice(c::BOLD.c::DARK_PURPLE."(!)". c::RESET.c::DARK_AQUA." CratePlugin Has been enabled"):
    }

    public function onCommand(CommandSender $sender , $Command $cnd, $label, $args)(
    if(strtolower($cnd->getName()) == "Cratekey")(
    $sender->isOp() {
    $sender->sendMessage(c::BOLD.c::DARK_PURPLE."(!)".c::DARK_AQUA." You have been given x1 common crate key!"):
    $sender->getInventory()->addItem(item::get(131:1,0,0));
    }elseif{!$sender->hasPermission("OP"))
    $sender->sendMessage(c::BOLD.c::DARK_RED."(!)".c::RESET.c::RED." Invalid Permissions"):
    }
    }
    }

    public function onDisable()}
    $this->getLogger()->warning(c::BOLD.c::DARK_RED."(!)".c::RESET.c::RED."CratePlugin has been disabled"):
    }
    }
    ?>

    id assume its the $array at the start of my code causing the issues.
     
  4. Sandertv

    Sandertv Zombie Pigman Poggit Reviewer

    Messages:
    786
    GitHub:
    Sandertv
    Please put your code in php blocks so we can actually read it. ([php][/php]) I've seen multiple issues in your code already, not sure about the original error.
     
    HimbeersaftLP and EdwardHamHam like this.
  5. Sandertv

    Sandertv Zombie Pigman Poggit Reviewer

    Messages:
    786
    GitHub:
    Sandertv
    Here, I've freed your code from the countless syntax errors and put it in a code block.
    PHP:
    <?php

    namespace CratePlugin_v1\CratePlugin_v;

    use 
    pocketmine\plugin\PluginBase;

    use 
    pocketmine\command\CommandSender;
    use 
    pocketmine\command\Command;

    use 
    pocketmine\item\Item;

    use 
    pocketmine\Player;
    use 
    pocketmine\Server;

    use 
    pocketmine\utils\TextFormat as c;

    class 
    Main extends PluginBase{

      public function 
    onEnable(){
        
    $this->getLogger()->notice(c::BOLD c::DARK_PURPLE "(!)" c::RESET.c::DARK_AQUA "CratePlugin Has been enabled");
      }

      public function 
    onCommand(CommandSender $senderCommand $cndstring $label, array $args) : bool{
        if(
    strtolower($cnd->getName()) === "cratekey"){
          if(
    $sender->isOp()){
            
    $sender->sendMessage(c::BOLD c::DARK_PURPLE "(!)" c::AQUA "You have been given x1 common crate key!");
            
    $sender->getInventory()->addItem(Item::get(131:1,0,0));
          }else{
            
    $sender->sendMessage(c::BOLD c::DARK_RED "(!)" c::RESET c::RED "InvalidPermissions");
          }
        }
        return 
    true;
      }

      public function 
    onDisable(){
        
    $this->getLogger()->warning(c::BOLD c::DARK_RED "(!)" c::RESET c::RED "CratePlugin has been disabled");
      }
    }
    Now please go learn how PHP works and how the syntax works. You're clearly not ready to use it yet :facepalm:
     
    Last edited: Aug 6, 2017
    HimbeersaftLP likes this.
  6. Lqchlan

    Lqchlan Creeper

    Messages:
    3
    GitHub:
    Lqchlan
     
  7. Awzaw

    Awzaw Zombie Pigman Poggit Admin

    Messages:
    726
    GitHub:
    awzaw
    You forgot to return a boolean in onCommand() :facepalm::p
     
    Sandertv likes this.
  8. Lqchlan

    Lqchlan Creeper

    Messages:
    3
    GitHub:
    Lqchlan
    I've learnt php just not familiar with the API. And I suppose this is my first time structuring a plugin and for that matter a php file.
     
  9. Sandertv

    Sandertv Zombie Pigman Poggit Reviewer

    Messages:
    786
    GitHub:
    Sandertv
    Whoops, you're right :p
     
  10. GamakCZ

    GamakCZ Zombie Pigman

    Messages:
    598
    GitHub:
    GamakCZ
    Strtolower will make you big letters to small so when you write $ cmd-> getName () with strtolower for Cratekey is logical that it will not work :D.
     
    Lqchlan likes this.
  11. Sandertv

    Sandertv Zombie Pigman Poggit Reviewer

    Messages:
    786
    GitHub:
    Sandertv
    Using the API was exactly the part you did do right. I found at least 1 syntax error each line of the plugin.
     
  12. Lqchlan

    Lqchlan Creeper

    Messages:
    3
    GitHub:
    Lqchlan
    Well thanks for the criticism but hey, I suppose I gotta keep going at it

    Thanks for the advice!

    Looking back at my code, I'm honestly ashamed the errors I made were so basic and I should be ashamed as I've made simple syntax errors

    Sorry for the frustration I've caused.
     
    Last edited by a moderator: Aug 6, 2017
  13. Lqchlan

    Lqchlan Creeper

    Messages:
    3
    GitHub:
    Lqchlan
    Thanks for the help, ik
    That I should of used the correct syntax format but that didn't solve the initial error
    I was having.
     
  14. Lqchlan

    Lqchlan Creeper

    Messages:
    3
    GitHub:
    Lqchlan
    My issue isn't resolved may I please have some assistance.
     
  15. Sandertv

    Sandertv Zombie Pigman Poggit Reviewer

    Messages:
    786
    GitHub:
    Sandertv
    Have you made sure all the permissions you check are actually registered? (in the plugin.yml)
     
  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.