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

Plugin not working

Comments in 'Plugin Development' started by zombie_Power, Oct 25, 2015.

  1. zombie_Power
    Offline

    zombie_Power Active Member

    Joined:
    Sep 7, 2015
    Posts:
    239
    Minecraft User:
    Zombie_Power
    Greetings,

    I have been working on a simple plugin, however unsure, why it isn't working. The console has not showed any error, but when I use the /plugins command in the server, Help_v1.0.0 is displayed in a red colour.

    My full plugin:
    PHP:
    <?php

    namespace Help;

    use 
    pocketmine\command\Command;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\utils\TextFormat;
    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\command\CommandSender;
    use 
    pocketmine\event\player\PlayerCommandPreproccessEvent;

    class 
    Main extends PluginBase implements Listener {

        public function 
    onEnable() {
             
    $this->getServer()->getPluginManager()->registerEvents($this$this);
       }

       public function 
    onChat(PlayerCommandPreproccessEvent $event) {
           
    $player $event->getPlayer();
           
    $chat explode(" "strtolower($event->getMessage()));
           if(
    $chat[0] == "/me" || $chat[0] == "/help"){
           
    $player->sendMessage(TextFormat::WHITE "[iLifePE]" TextFormat::BLUE "Please use /h for help");
           
    $event->setCancelled();
          }
       }
      public function 
    onCommand(CommandSender $senderCommand $command$label, array $args){
        
    $cmd strtolower($command->getName());
        if(
    $cmd === "h"){
          
    $sender->sendMessage(TextFormat::WHITE "[iLifePE]" TextFormat::BLUE "Welcome" $player ."!");
          
    $sender->sendMessage(TextFormat::WHITE "[iLifePE]" TextFormat::BLUE "Please use the portals to teleport");
          
    $sender->sendMessage(TextFormat::WHITE "-=+=- iLifePE Network -=+=-");
          return 
    true;
          }
      return 
    false;
      }
    }




        
    EDIT: fixed "Weclome"

    Any help appreciated :D
    Last edited: Oct 25, 2015
  2. jojoe77777
    Offline

    jojoe77777 Notable Member Plugin Developer

    Joined:
    May 28, 2015
    Posts:
    653
    Plugins:
    1
    Minecraft User:
    jojoe77777
    Are you sure that's the whole code? It's missing at least 2 brackets...

    EDIT: And there's a typo in one of the messages... "Weclome"
    zombie_Power likes this.
  3. zombie_Power
    Offline

    zombie_Power Active Member

    Joined:
    Sep 7, 2015
    Posts:
    239
    Minecraft User:
    Zombie_Power
    you mean after /me and before $chat?
    Sorry I can be wrong and that is the full plugin
  4. jojoe77777
    Offline

    jojoe77777 Notable Member Plugin Developer

    Joined:
    May 28, 2015
    Posts:
    653
    Plugins:
    1
    Minecraft User:
    jojoe77777
    No, you need to put 2 closing curly brackets "}" at the end of your current code.
    zombie_Power likes this.
  5. zombie_Power
    Offline

    zombie_Power Active Member

    Joined:
    Sep 7, 2015
    Posts:
    239
    Minecraft User:
    Zombie_Power
    Wouldn't that cause an error? *look after return false;"
    Last edited: Oct 25, 2015
  6. jojoe77777
    Offline

    jojoe77777 Notable Member Plugin Developer

    Joined:
    May 28, 2015
    Posts:
    653
    Plugins:
    1
    Minecraft User:
    jojoe77777
    Ok that's fixed... Can you please try posting your server console with the plugin installed?
    zombie_Power likes this.
  7. zombie_Power
    Offline

    zombie_Power Active Member

    Joined:
    Sep 7, 2015
    Posts:
    239
    Minecraft User:
    Zombie_Power
    I tried again, but with Devtools and ZipPluginLoader and received:
    Code:
    Server thread/INFO Plugin Help is not in folder structure.
    
    My .zip file at the bottom

    Attached Files:

  8. jojoe77777
    Offline

    jojoe77777 Notable Member Plugin Developer

    Joined:
    May 28, 2015
    Posts:
    653
    Plugins:
    1
    Minecraft User:
    jojoe77777
    I ran it and got this:
    Code:
    [03:10:38] [Server thread/INFO]: Enabling Help v1.0.0
    [03:10:38] [Server thread/CRITICAL]: ReflectionException: "Class pocketmine\event\player\PlayerCommandPreproccessEvent does not exist" (EXCEPTION) in "/src/pocketmine/plugin/PluginManager" at line 724
    [03:10:38] [Server thread/INFO]: Disabling Help v1.0.0
    
    zombie_Power likes this.
  9. zombie_Power
    Offline

    zombie_Power Active Member

    Joined:
    Sep 7, 2015
    Posts:
    239
    Minecraft User:
    Zombie_Power
    Thanks! I spelt "PlayerCommandPreproccessEvent" wrong, it meant to be PlayerCommandProcessEvent, however the plugin still doesn't work ;/
    Last edited: Oct 25, 2015
  10. MCPEPIG
    Offline

    MCPEPIG Notable Member

    Joined:
    Jun 22, 2014
    Posts:
    349
    Minecraft User:
    MCPEPIG
    Try without ZipPluginLoader.
    zombie_Power likes this.
  11. zombie_Power
    Offline

    zombie_Power Active Member

    Joined:
    Sep 7, 2015
    Posts:
    239
    Minecraft User:
    Zombie_Power
    got this :(
    Code:
    UnexpectedValueException: "manifest cannot be larger than 100 MB in phar "/plugins/Help_v1.0.0.phar"" (EXCEPTION) in "/src/pocketmine/plugin/PharPluginLoader" at line 85
    24.10 22:52:21 [Server] Server thread/ERROR Could not load '/plugins/Help_v1.0.0.phar' in folder '/plugins/': manifest cannot be larger than 100 MB in phar "/plugins/Help_v1.0.0.phar"
    
    it isn't larger than 100mb :/
  12. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    The size comes from the declaration within the phar, not from the actual file size. That means that your phar file is corrupted.
    zombie_Power likes this.
  13. zombie_Power
    Offline

    zombie_Power Active Member

    Joined:
    Sep 7, 2015
    Posts:
    239
    Minecraft User:
    Zombie_Power
    Code:
    Server thread/CRITICAL ReflectionException: "Class Help\PlayerCommandPreproccessEvent does not exist" (EXCEPTION) in "/src/pocketmine/plugin/PluginManager" at line 724
    
    I keep getting the same error even tho I changed it
    Update:
    PHP:
    <?php

    namespace Help;

    use 
    pocketmine\command\Command;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\utils\TextFormat;
    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\command\CommandSender;
    use 
    pocketmine\event\player\PlayerCommandPreprocessEvent;

    class 
    Main extends PluginBase implements Listener {

        public function 
    onEnable() {
             
    $this->getServer()->getPluginManager()->registerEvents($this$this);
       }
      
       public function 
    onChat(PlayerCommandPreprocessEvent $event) {
           
    $player $event->getPlayer();
           
    $chat explode(" "strtolower($event->getMessage()));
           if(
    $chat[0] == "/me" || $chat[0] == "/help"){
           
    $player->sendMessage(TextFormat::WHITE "[iLifePE]" TextFormat::BLUE "Please use /h for help");
           
    $event->setCancelled();
          }
       }
      public function 
    onCommand(CommandSender $senderCommand $command$label, array $args){
        
    $cmd strtolower($command->getName());
        if(
    $cmd === "h"){
          
    $sender->sendMessage(TextFormat::WHITE "[iLifePE]" TextFormat::BLUE "Welcome" $player ."!");
          
    $sender->sendMessage(TextFormat::WHITE "[iLifePE]" TextFormat::BLUE "Please use the portals to teleport");
          
    $sender->sendMessage(TextFormat::WHITE "-=+=- iLifePE Network -=+=-");
          return 
    true;
        }
        return 
    false;
      }
    }

     

    Last edited: Oct 25, 2015
  14. MCPEPIG
    Offline

    MCPEPIG Notable Member

    Joined:
    Jun 22, 2014
    Posts:
    349
    Minecraft User:
    MCPEPIG
    PHP:
    public function onChat(PlayerCommandPreproccessEvent $event){
    }
    should be
    PHP:
    public function onChat(PlayerCommandPreprocessEvent $event){
    }
    zombie_Power and PEMapModder like this.
  15. zombie_Power
    Offline

    zombie_Power Active Member

    Joined:
    Sep 7, 2015
    Posts:
    239
    Minecraft User:
    Zombie_Power
    That is what I did, check the updated version
  16. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    You had an extra "c".
    zombie_Power likes this.
  17. zombie_Power
    Offline

    zombie_Power Active Member

    Joined:
    Sep 7, 2015
    Posts:
    239
    Minecraft User:
    Zombie_Power
    Greetings,

    The plugin itself have worked (changed /help and /me), however, it hasn't created the /h command

    the server displays: An unknown error occurred while attempting to perform this command
    Last edited: Oct 25, 2015
  18. MCPEPIG
    Offline

    MCPEPIG Notable Member

    Joined:
    Jun 22, 2014
    Posts:
    349
    Minecraft User:
    MCPEPIG
    Register the command in plugin.yml
  19. zombie_Power
    Offline

    zombie_Power Active Member

    Joined:
    Sep 7, 2015
    Posts:
    239
    Minecraft User:
    Zombie_Power
    plugin.yml
    Code:
    name: Help
    main: Help\Main
    version: 1.0.0
    api: [1.2.0]
    author: Zombie
    description: helps the player
    commands:
        h:
            description: alternative to /help
            usage: /h
         
    
    
  20. jojoe77777
    Offline

    jojoe77777 Notable Member Plugin Developer

    Joined:
    May 28, 2015
    Posts:
    653
    Plugins:
    1
    Minecraft User:
    jojoe77777
    oops... I tried to tell you that, but my browser glitched.
    zombie_Power likes this.

Share This Page

Advertisement