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

New at coding

Discussion in 'Development' started by YoungJ, Apr 24, 2020.

  1. YoungJ

    YoungJ Creeper

    Messages:
    3
    GitHub:
    youngjmc
    Hi guys I just have a question what am I doing wrong here I am barely new to coding and hopefully some of you guys can help me out I will send all the error if needed ty!

    PHP:
    <?php

    namespace exepx\placeblock;

    use 
    pocketmine\event\block\BlockBreakEvent;
    use 
    pocketmine\event\block\BlockPlaceEvent;
    use 
    pocketmine\network\mcpe\protocol\BlockActorDataPacket;
    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\command\Command;
    use 
    pocketmine\command\CommandSender;
    use 
    pocketmine\Server;
    use 
    pocketmine\Player;
    use 
    pocketmine\utils\TextFormat;
    use 
    pocketmine\block\Block;
    use 
    pocketmine\event\Cancellable;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\item\Item;

    class 
    Main extends PluginBase implements Listener {

        public function 
    onEnable() {
            
    $this->getServer()->getPluginManager()->registerEvents($this$this);
            
    $this->getLogger()->info(TextFormat::DARK_GREEN "Place block has been enabled!");
        }

        public function 
    onDisable() {
            
    $this->getLogger()->info(TextFormat::DARK_RED "Place block has been disabled");
        }

        public function 
    onCommand(CommandSender $senderCommand $commandstring $label, array $args) : bool {
            switch (
    $command->getName()) {
                case 
    "on":
                    
    $sender->sendMessage(TextFormat::DARK_GREEN "You can now place blocks");
                        return 
    true;
                case 
    "off":
                    
    $sender->sendMessage(TextFormat::DARK_RED "You cant place blocks!");
                    return 
    true;
            }
        }
    }
     
  2. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    What is the intended outcome and what is the outcome you are seeing?
     
  3. YoungJ

    YoungJ Creeper

    Messages:
    3
    GitHub:
    youngjmc
    hi @jasonwynn10

    as of right now my intended outcome is just making it a command but everytime I do it gives me an error on the console and it unloads I will send what error it gives me



    Code:
     TypeError: "strpos() expects parameter 1 to be string, int given" (EXCEPTION) in "src/pocketmine/plugin/PluginManager" at line 560
    [23:16:14] [Server thread/DEBUG]: #0 src/pocketmine/plugin/PluginManager(560): strpos(integer 1, string[1] :)
     
  4. NTT

    NTT Zombie

    Messages:
    311
    GitHub:
    NTT1906
    You should have a look at php
     
  5. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
    I think this has sth to do with the stupidness of yaml replacing "on" with "true". Try naming the command differently.
     
  6. YoungJ

    YoungJ Creeper

    Messages:
    3
    GitHub:
    youngjmc

    I will try that thank you :)
     
  7. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    ... no if you look at the actual error posted it says it was an integer, not a string. It actually was what it was, not what it needed to be.
     
  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.