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

Solved Plugin Error

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

  1. MrReskill
    Offline

    MrReskill New Member

    Joined:
    Sep 21, 2015
    Posts:
    29
    Minecraft User:
    MrReskillYT
    Hello,
    I'm working on a plugin but I have a problem,
    when I made / joinhg his works but /jointtf told me that the command does not exist!
    Here's the 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 . "Enable !");
    }

    public function onDisable(){
    $this->getLogger()->info(TextFormat::DARK_RED . "disabled!");
    }
    public function onCommandChat(PlayerCommandPreprocessEvent $event){
    $player = $event->getPlayer();
    $cmd = explode(" ",strtolower($event->getmessage()));
    if($cmd[0] == "/home" or $cmd[0] == "/sethome" or $cmd[0] == "/claim" or $cmd[0] == "/unclaim" or $cmd[0] == "/me"){
    $pos = $player->getName();
    if($player->getLevel()->getName() == "HUB"){
    $player->sendMessage("§6[§5HUB§6]§c This command is not allowed in the§c Destiny Lobby");
    $event->setCancelled(true);
    }
    }
    if($cmd[0] == "tg" or $cmd[0] == "connard" or $cmd[0] == ".fr" or $cmd[0] == ".leet.cc" or $cmd[0] == ".mcpe.eu"){
    $player->sendMessage("§6[§5MODO§6]§c Please not spam this message !");
    $event->setCancelled(true);
    }
    }
    public function onCommand(CommandSender $sender, Command $cmd, $label, array $args){
    switch($cmd->getName()){
    case "joinhg":
    if($sender->hasPermission("m.joinhg")){
    $sender->sendMessage(" c");

    }else{
    $sender->sendMessage(TextFormat::RED . "You Don't Have Permissions To Run This Command");
    }
    return true;
    break;

    case "jointtf":
    if($sender->hasPermission("m.jointtf")){
    $sender->sendMessage(" ca");

    }else{
    $sender->sendMessage(TextFormat::RED . "You Don't Have Permissions To Run This Command");
    }
    return true;
    break;
    }
    }
    }


    Thanks you,

  2. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    Show your plugin.yml please
  3. MrReskill
    Offline

    MrReskill New Member

    Joined:
    Sep 21, 2015
    Posts:
    29
    Minecraft User:
    MrReskillYT
    I have found the error thank !

    Ps: Im french my english is bad
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Next time mind putting your code in [php][/php], and do not make them italic.
    KubixQ likes this.

Share This Page

Advertisement