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

Something is wrong - Nothing is happening

Discussion in 'Development' started by InspectorGadget, Jan 21, 2017.

  1. InspectorGadget

    InspectorGadget Zombie Pigman

    Messages:
    462
    GitHub:
    InspectorGadget
    Hi! I've been thinking about this plugin :D

    Here's my Main a.k.a "Review.php":
    PHP:

    <?php

    namespace RTG\GitHub;

    /*
     * All rights reserved RTGNetworkkk
     */

    /* Essentials */
    use pocketmine\Player;
    use 
    pocketmine\Server;
    use 
    pocketmine\plugin\PluginBase;

    class 
    Review extends PluginBase {
      
        public function 
    onEnable() {
            @
    mkdir($this->getDataFolder());
            @
    mkdir($this->getDataFolder() . "/players");
            
    $this->getLogger()->warning("[Review] DIR has been made!");
          
            
    /* Execution */
            
    $this->setExecutor(new MyCommand($this));
          
            
    $this->getLogger()->warning("[Review] Everything has been loaded!");
        }
      
        public function 
    onDisable() {
        }
      
    }
    Here's MyCommand:
    PHP:

    <?php

    namespace RTG\GitHub\Command;

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

    use 
    pocketmine\utils\Config;

    use 
    RTG\GitHub\Review;

    use 
    pocketmine\utils\TextFormat as TF;

    class 
    MyCommand implements CommandExecutor {
      
        public function 
    __construct(Review $plugin) {
            
    $this->plugin $plugin;
        }
      
        public function 
    onCommand(CommandSender $senderCommand $cmd$label, array $param) {
            switch(
    $cmd->getName()) {
              
                case 
    "review":
                  
                    if(isset(
    $param[0])) {
                      
                        switch(
    $param[0]) {
                          
                            case 
    "add":
                              
                                if(
    $sender->hasPermission("review.add")) {
                  
                                    
    $n $sender->getName();
                  
                                    if(
    count($param) < 1) return false;
                  
                                        
    $msg trim(implode(" "$param));
                      
                                         
    $this->cfg = new Config($this->getDataFolder() . "/players" $n "yml"Config::YAML);
                      
                                         
    $this->cfg->setNested($msg);
                      
                                         
    $sender->sendMessage("[Review] You review has been added!");
                          
                                }
                                else {
                                    
    $sender->sendMessage(TF::RED "You have no permission to use this command!");
                                } 
                              
                                return 
    true;
                            break;       
                          
                        }
                    }
                    else {
                        
    $sender->sendMessage("Usage: /review add {review}");
                    }
                  
                    return 
    true;
                break;
              
            }
          
        }
      
    }
    Plugin.yml:
    PHP:
    nameReviewer
    version
    1.0.0
    main
    RTG\GitHub\Review
    api
    2.1.0
    commands
    :
        
    review:
            
    permissionreview.add
            description
    "Adds review!"
    permissions:
        
    review.add:
            default: 
    op

    No errors has been encountered on Console...

    GitHub src: https://github.com/RTGNetworkkk/Reviewer
     
  2. eDroid

    eDroid Witch

    Messages:
    59
    GitHub:
    edroiid
    i think you need to also have
    PHP:
    use RTG\GitHub\Command\MyCommand;
    in main aka Review.php
     
    applqpak likes this.
  3. wolfdale

    wolfdale Zombie Pigman

    Messages:
    535
    GitHub:
    diamond-gold
    Is the plugin even loaded?
     
  4. InspectorGadget

    InspectorGadget Zombie Pigman

    Messages:
    462
    GitHub:
    InspectorGadget
    It is loaded...
     
  5. wolfdale

    wolfdale Zombie Pigman

    Messages:
    535
    GitHub:
    diamond-gold
    Do you see the 2 warning messages on console?
     
  6. InspectorGadget

    InspectorGadget Zombie Pigman

    Messages:
    462
    GitHub:
    InspectorGadget
    Nope.. Multicraft hides it. Can u show me the error? I'll be installing PMMP on my Machine
     
    Last edited: Jan 21, 2017
  7. wolfdale

    wolfdale Zombie Pigman

    Messages:
    535
    GitHub:
    diamond-gold
    I cant test it now, will test later at night
     
  8. InspectorGadget

    InspectorGadget Zombie Pigman

    Messages:
    462
    GitHub:
    InspectorGadget
    Thanks
     
  9. wolfdale

    wolfdale Zombie Pigman

    Messages:
    535
    GitHub:
    diamond-gold
    I spotted 4 errors, 1 is what @eDroid pointed out eariler, you need to
    PHP:
    use RTG\GitHub\Command\MyCommand;
    second is
    Code:
    Error: "Call to undefined method RTG\GitHub\Command\MyCommand::getDataFolder()" (EXCEPTION) in "src/RTG/GitHub/Command/MyCommand" at line 40
    after fixing all those i got another error
    Code:
    Missing argument 2 for pocketmine\utils\Config::setNested(), called in src\RTG\GitHub\Command\MyCommand.php on line 42
    And finally you did not save the config.
     
  10. corytortoise

    corytortoise Skeleton

    Messages:
    825
    GitHub:
    corytortoise
    Why did you use getLogger()->warning()? Unless you use it to throw errors, wouldn't getLogger()->notice() be better?
     
  11. Junkdude

    Junkdude Zombie

    Messages:
    346
    GitHub:
    JunkDaCoder
    PHP:
    nameReviewer
    version
    1.0.0
    main
    RTG\GitHub\Review
    api
    2.1.0
    commands
    :
      
    review:
        
    permissionreview.add
        description
    "Adds review!"
    permissions:
        
    review.add:
            default: 
    op
    Please use spaces instead of tabs next time...
     
  12. InspectorGadget

    InspectorGadget Zombie Pigman

    Messages:
    462
    GitHub:
    InspectorGadget
    NetBeans IDE sets the space for the YAML file
     
  13. InspectorGadget

    InspectorGadget Zombie Pigman

    Messages:
    462
    GitHub:
    InspectorGadget
    Noted, 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.