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

Error command php

Comments in 'Plugin Development' started by MrReskill, Feb 25, 2016.

  1. MrReskill
    Offline

    MrReskill New Member

    Joined:
    Sep 21, 2015
    Posts:
    29
    Minecraft User:
    MrReskillYT
    Hi, I have but this one startup plugin execute a single command on any one I programmed while the other controls do not work (this / joinhg works).

    plugin.yml:
    Code:
    name: reskill
    main: reskill\MainClass
    version: 1.0.0
    api: [1.0.0]
    
    load: POSTWORLD
    author: MrReskill
    description: Plugin base
    website: https://destinype.fr
    commands:
    joinhg:
      description: join HG
      usage: "Usage: /joinhg"
      permission: msg.command.hg
    jointtf:
      description: join ttf
      usage: "Usage: /jointtf"
      permission: msg.command.ttf
    joinsr:
      description: join sr
      usage: "Usage: /joinsr"
      permission: msg.command.sr
    lobbyvip:
      description: lobbyvip
      usage: "Usage: /lobbyvip"
      permission: msg.command.vip
    joinoff:
      description: join OFF game
      usage: "Usage: /joinoff"
      permission: msg.command.off
    permissions:
    msg.command.hg:
      description: "Run /joinhg command!"
      default: true
    msg.command.ttf:
      description: "Run /jointtf command!"
      default: true
    msg.command.sr:
      description: "Run /joinsr command!"
      default: true
    msg.command.vip:
      description: "Run /lobbyvip command!"
      default: true
    msg.command.off:
      description: "Run /joinoff command!"
      default: true
    
    
    MainClass.php:


    Code:
    <?php
    
    namespace reskill;
    
    use pocketmine\command\Command;
    use pocketmine\command\CommandSender;
    use pocketmine\event\Listener;
    use pocketmine\event\player\PlayerRespawnEvent;
    use pocketmine\event\player\PlayerCommandPreprocessEvent;
    use pocketmine\Player;
    use pocketmine\plugin\PluginBase;
    use pocketmine\Server;
    use pocketmine\utils\TextFormat;
    
    class MainClass extends PluginBase implements Listener{
    
        public function onLoad(){
            $this->getLogger()->info(TextFormat::WHITE . "DarkRealmsCore has been loaded!");
        }
    
        public function onEnable(){
            $this->getServer()->getPluginManager()->registerEvents($this, $this);
            $this->getLogger()->info(TextFormat::DARK_GREEN . "DarkRealmsCore has been enabled!");
        }
    
        public function onDisable(){
            $this->getLogger()->info(TextFormat::DARK_RED . "DarkRealmsCore has been disabled!");
        }
        public function onDamage(EntityDamageEvent $event){
           if($event->getEntity() instanceof Player){
           if($event->getCause() == EntityDamageEvent::CAUSE_FALL){
           $event->setCancelled();
      }
    }
    }
        public function onCommandChat(PlayerCommandPreprocessEvent $event){
           $player = $event->getPlayer();
           $cmd = explode(" ",strtolower($event->getmessage()));
          if($cmd[0] == "/buhc" or $cmd[0] == "/tg" or $cmd[0] == "/claim" or $cmd[0] == "/unclaim" or $cmd[0] == "/me"){
           $pos = $player->getName();
          if($player->getLevel()->getName() == "spawn"){
           $player->sendMessage("§6[§5HUB§6]§c Ces commandes ne sont pas executable au lobby de §cBadlion§lPE");
           $event->setCancelled(true);
        }
        }
        if($cmd[0] == "tg" or $cmd[0] == "connard" or $cmd[0] == "ez" or $cmd[0] == "eZ" or $cmd[0] == "putin"){
           $player->sendMessage("§6[§5MODO§6]§c Vous avez cité un mot interdit par notre AntiCheat");
           $event->setCancelled(true);
        }
        }
        if($cmd[0] == "pl" or $cmd[0] == "help" or $cmd[0] == "version"){
           $player->sendMessage("§6[§5BadlionPE§6]§c NON! L'originalité est la recette du bon fonctionnement d'un serveur ! Cette commande à étez bloqué.");
           $event->setCancelled(true);
        }
        }
        public function onCommand(CommandSender $sender, Command $command, $label, array $args){
            switch($command->getName()){
                case "joinhg":
                    $sender->sendMessage("§5§l=========================");
                    $sender->sendMessage("§aYou have selected the game.");
                    $sender->sendMessage("§aGame: §cHungerGames");
                    $sender->sendMessage("§5§l=========================");
                    return true;
                case "jointtf":
                    $sender->sendMessage("§5§l=========================");
                    $sender->sendMessage("§aYou have selected the game.");
                    $sender->sendMessage("§aGame: §cTouchTheFlag (TTF)");
                    $sender->sendMessage("§5§l=========================");
                    return true;
                case "joinsr":
                    $sender->sendMessage("§5§l=========================");
                    $sender->sendMessage("§aYou have selected the game.");
                    $sender->sendMessage("§aGame: §cSurvie | Survival");
                    $sender->sendMessage("§5§l=========================");
                    return true;
    
                case "lobbyvip":
                    $sender->sendMessage("§5§l=========================");
                    $sender->sendMessage("§aYou have been teleported to");
                    $sender->sendMessage("§aGame: §3Lobby VIP");
                    $sender->sendMessage("§5§l=========================");  
                    return true;
    
                case "joinoff":
                    $sender->sendMessage("§5§l=========================");
                    $sender->sendMessage("§aThis game is disabled");
                    $sender->sendMessage("§aReason: §cMaintenance Break ");
                    $sender->sendMessage("§5§l=========================");  
                    return true;
    
            }
        }
    }
    

    Thanks you.
  2. TutoGamerWalid
    Offline

    TutoGamerWalid Active Member

    Joined:
    Jun 11, 2015
    Posts:
    69
    Minecraft User:
    TutoGamerWalid
    Do You have a crashdump ? Use break; And remove return true; because your command not finished
    Last edited: Feb 25, 2016
  3. MrReskill
    Offline

    MrReskill New Member

    Joined:
    Sep 21, 2015
    Posts:
    29
    Minecraft User:
    MrReskillYT
    Thanks im idiot.
    TutoGamerWalid likes this.
  4. TutoGamerWalid
    Offline

    TutoGamerWalid Active Member

    Joined:
    Jun 11, 2015
    Posts:
    69
    Minecraft User:
    TutoGamerWalid
    You are not idiot You is my friend :)
  5. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    return; exits the function, that does work too.
  6. TutoGamerWalid
    Offline

    TutoGamerWalid Active Member

    Joined:
    Jun 11, 2015
    Posts:
    69
    Minecraft User:
    TutoGamerWalid
    yes but it does not use the break;
  7. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    HotFireyDeath likes this.
  8. TutoGamerWalid
    Offline

    TutoGamerWalid Active Member

    Joined:
    Jun 11, 2015
    Posts:
    69
    Minecraft User:
    TutoGamerWalid
  9. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    There is perfectly nothing wrong with return true. If you returned from the function, you don't need to break the switch anymore, because you already exited the whole function.
    Please stop posting wrong replies on the forums.
    CraftYourBukkit and applqpak like this.
  10. Yosshi999
    Offline

    Yosshi999 New Member Plugin Developer

    Joined:
    Mar 13, 2014
    Posts:
    29
    Plugins:
    1
    Minecraft User:
    Yosshi999
    What will happen if you change the order?
    for example,
    change
    Code:
    commands:
    joinhg:
    ...
    
    into
    Code:
    commands:
    jointtf:
    ...
    
  11. TutoGamerWalid
    Offline

    TutoGamerWalid Active Member

    Joined:
    Jun 11, 2015
    Posts:
    69
    Minecraft User:
    TutoGamerWalid
    I listen to the plugin help for her from now the plugin works with the " break; " I send messages I want.
  12. Vaivez66
    Offline

    Vaivez66 Notable Member Plugin Developer

    Joined:
    Jun 10, 2015
    Posts:
    402
    Plugins:
    2
    I don't understand what you mean...
    applqpak likes this.
  13. TheDeibo
    Offline

    TheDeibo Notable Member

    Joined:
    Sep 8, 2014
    Posts:
    693
    Minecraft User:
    TheDeibo
    Nothing really. Think of it as simply referencing what the plugin's commands. in referencing, it doesn't matter much about the order, its just simply easier. It's basically the author's decision what order it's in. Feel free to test it out though.
    TutoGamerWalid likes this.
  14. TutoGamerWalid
    Offline

    TutoGamerWalid Active Member

    Joined:
    Jun 11, 2015
    Posts:
    69
    Minecraft User:
    TutoGamerWalid
    do not worry so...
  15. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    "now the plugin works"?
    [​IMG]
    TheDeibo and Exxarion like this.

Share This Page

Advertisement