Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Commands don't work?

Comments in 'Plugin Development' started by minebuilder0110, Dec 29, 2015.

  1. minebuilder0110
    Offline

    minebuilder0110 Notable Member

    Joined:
    Dec 8, 2014
    Posts:
    485
    Minecraft User:
    Apparitional
    PHP:
            case "starttime":
            
    $start time();
            
    $sender->sendMessage("start");
            break;
            case 
    "stoptime":
            
    $end time();
            
    $time $end $start;
            if(
    $time 60){
            
    $sec $time 60;
            
    $min floor($time 60);
            
    $sender->sendMessage("Time is:");
            
    $sender->sendMessage($time);
            
    $sender->sendMessage($min ":" $sec);
            break;
    This is how I made my stopwatch feature inside my big plugin, yet it does not function. Every commands other than these two works. I don't have a decent knowledge of tasks, which is why I am using this. However, nothing is being returned, even "start". I checked plugin.yml, and /help, but they were there. What could be the problem?
  2. minebuilder0110
    Offline

    minebuilder0110 Notable Member

    Joined:
    Dec 8, 2014
    Posts:
    485
    Minecraft User:
    Apparitional
    Yes, as I stated above.
  3. TomDohrmann
    Offline

    TomDohrmann New Member

    Joined:
    Sep 15, 2015
    Posts:
    3
    Minecraft User:
    TomDohrmann
    Sry I cant read xD
    Can you send the complete Method?
  4. applqpak
    Offline

    applqpak Active Member Plugin Developer

    Joined:
    Dec 16, 2015
    Posts:
    284
    Plugins:
    1
    Minecraft User:
    applqpak
    Are you returning them?
  5. Vaivez66
    Offline

    Vaivez66 Notable Member Plugin Developer

    Joined:
    Jun 10, 2015
    Posts:
    402
    Plugins:
    2
    Did you put it on your Main class?
  6. minebuilder0110
    Offline

    minebuilder0110 Notable Member

    Joined:
    Dec 8, 2014
    Posts:
    485
    Minecraft User:
    Apparitional
    PHP:
      public function onCommand(CommandSender $senderCommand $cmd$label, array $args){
        
    $command = (strtolower($cmd->getName()));
        if(
    $command === "pp" || $command === "parkourplus"){
            if(!isset(
    $args[0])){
            
    $sender->sendMessage("---------------ParkourPlus---------------");
            
    $sender->sendMessage("/pp info: Gives you information about PP");
            return 
    true;
            }
            switch(
    $command){
            case 
    "i":
            case 
    "info":
            
    $sender->sendMessage("ParkourPlus developed by" TextFormat::GREEN " HerO_0110 (Apparitional)");
            return 
    true;
            break;
            case 
    "s":
            case 
    "setup":
            if(
    $sender->hasPermission("pp.setup")){
            
    //removed
            
    }
            break;
            case 
    "starttime":
                
    $beginning time();
                
    $sender->sendMessage("start");
                break;
            case 
    "stoptime":
                
    $end time();
                
    $time $end $beginning;
                if(
    $time 60){
                
    $sec $time 60;
                
    $min floor($time 60);
                
    $sender->sendMessage("Time is:");
                
    $sender->sendMessage($time);
                
    $sender->sendMessage($min ":" $sec);
                break;
            default:
            
    $sender->sendMessage(TextFormat::RED "Please use /pp help for list of commands.");
        }
        return 
    true;
        }
      }
      }
    I don't see how it can fail, at least for me.
  7. Vaivez66
    Offline

    Vaivez66 Notable Member Plugin Developer

    Joined:
    Jun 10, 2015
    Posts:
    402
    Plugins:
    2
  8. minebuilder0110
    Offline

    minebuilder0110 Notable Member

    Joined:
    Dec 8, 2014
    Posts:
    485
    Minecraft User:
    Apparitional
    Oh yeah, forgot to answer that. Yes, everything other than these two commands work. Even if they now don't, they used to work.
  9. TomDohrmann
    Offline

    TomDohrmann New Member

    Joined:
    Sep 15, 2015
    Posts:
    3
    Minecraft User:
    TomDohrmann
    'case "i":
    case "info":'

    You forgot "break;"
  10. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    He didn't want to break it...
  11. minebuilder0110
    Offline

    minebuilder0110 Notable Member

    Joined:
    Dec 8, 2014
    Posts:
    485
    Minecraft User:
    Apparitional
    I noticed that I made lots of mistakes including missing breaks (excluding tom's one) and undefined variables while removing some parts and in my actual code. However, it seems that Devtools says it is loaded, but it somehow doesn't work.
  12. minebuilder0110
    Offline

    minebuilder0110 Notable Member

    Joined:
    Dec 8, 2014
    Posts:
    485
    Minecraft User:
    Apparitional
    upload_2015-12-30_1-4-4.png
    This is the problem I'm currently having. It is only returning the usage even when I use it correctly.
    I also have
    PHP:
    $this->getLogger()->info(TextFormat::GREEN "Thank you for using ParkourPlus. This plugin is developed by HerO_0110 (Apparitional).");
    , but it does not come up.
    upload_2015-12-30_1-6-10.png
    PS: Do you even sleep, @PEMapModder?
  13. TomDohrmann
    Offline

    TomDohrmann New Member

    Joined:
    Sep 15, 2015
    Posts:
    3
    Minecraft User:
    TomDohrmann
    Add "load: POSTWORLD" in your plugin.yml
  14. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    @shoghicp codes in his dreams. I dream in my code.
    It is just 12:46 a.m. right now, quite early for me in holidays.
    Did you return true?
    This is completely irrelevant. And no, adding that line is same as not adding.
    minebuilder0110 likes this.
  15. minebuilder0110
    Offline

    minebuilder0110 Notable Member

    Joined:
    Dec 8, 2014
    Posts:
    485
    Minecraft User:
    Apparitional
    Yup. I already tried it with that too.

Share This Page

Advertisement