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

Solved Simple message reply by command

Comments in 'Plugin Development' started by TheDeibo, Oct 16, 2015.

  1. TheDeibo
    Offline

    TheDeibo Notable Member

    Joined:
    Sep 8, 2014
    Posts:
    693
    Minecraft User:
    TheDeibo
    Basically, can someone correct ( or fix ) my code please.

    PHP
    Code:
    <?php
    namespace thedeibo\ServerLoveExt;
    use pocketmine\command\Command;
    use pocketmine\command\ComamndSender;
    class Main extends PluginBase{
    public function onEnable(){
    // $this->getServer()->getPluginManager()->registerEvents($this, $this);
    }
    public function onCommand(CommandSender $sender, Command $command, $label, array $args){
    $commandName = $command->getName();
    if($commandName === "greet"){
    $sender->sendMessage("Hi!");
    return true;
    }
    return false;
    }
    
    plugin.yml
    Code:
    name: ServerLoveExt
    version: 1.0.0
    author: TheDeibo
    api: 1.12.0
    main: TheDeibo\ServerLoveExt\main
    commands:
        serverlove:
            description: Gives all importent infomation about the plugin.
                usage: /serverlove Gives all important infomation about the plugin.    
    permissions:
        serverlove.serverlove:
            default: true
            description: Allows user to use /serverlove
    
    It keeps coming up with this error below
    PocketMine-MP Crash Dump Fri Oct 16 13:39:52 UTC 2015

    Error: Class thedeibo\ServerLoveExt\Main not found
    File: /src/spl/BaseClassLoader
    Line: 144
    Type: notice

    THIS CRASH WAS CAUSED BY A PLUGIN

    Code:
    [135]
    [136] if(\method_exists($name, "onClassLoaded") and (new ReflectionClass($name))->getMethod("onClassLoaded")->isStatic()){
    [137] $name::eek:nClassLoaded();
    [138] }
    [139]
    [140] $this->classes[] = $name;
    [141]
    [142] return \true;
    [143] }elseif($this->getParent() === \null){
    [144] throw new ClassNotFoundException("Class $name not found");
    [145] }
    [146]
    [147] return \false;
    [148] }
    [149]
    [150] /**
    [151] * Returns the path for the class, if any
    [152] *
    [153] * @param string $name
    [154] *

    Backtrace:
    #0 (): spl_autoload_call(string thedeibo\ServerLoveExt\Main)
    #1 /src/pocketmine/plugin/PharPluginLoader(64): class_exists(string thedeibo\ServerLoveExt\Main, boolean 1)
    #2 /src/pocketmine/plugin/PluginManager(152): pocketmine\plugin\PharPluginLoader->loadPlugin(string C:\Users\TheDeibo\Documents\PocketMine-MP\plugins\8n3UsVHoWFU_.phar)
    #3 /src/pocketmine/plugin/PluginManager(296): pocketmine\plugin\PluginManager->loadPlugin(string C:\Users\TheDeibo\Documents\PocketMine-MP\plugins\8n3UsVHoWFU_.phar, array Array())
    #4 /src/pocketmine/Server__32bit(1633): pocketmine\plugin\PluginManager->loadPlugins(string C:\Users\TheDeibo\Documents\PocketMine-MP\plugins\)
    #5 /src/pocketmine/PocketMine(464): pocketmine\Server->__construct(pocketmine\CompatibleClassLoader object, pocketmine\utils\MainLogger object, string phar://C:/Users/TheDeibo/Documents/PocketMine-MP/PocketMine-MP.phar/, string C:\Users\TheDeibo\Documents\PocketMine-MP\, string C:\Users\TheDeibo\Documents\PocketMine-MP\plugins\)
    #6 (1): require(string phar://C:/Users/TheDeibo/Documents/PocketMine-MP/PocketMine-MP.phar/src/pocketmine/PocketMine.php)

    PocketMine-MP version: 1.6dev #35 [Protocol 34; API 1.13.0]
    Git commit: 0000000000000000000000000000000000000000
    uname -a: Windows NT TheDeibo-PC 6.2 build 9200 (Windows 8 Business Edition) i586
    PHP Version: 5.6.6
    Zend version: 2.6.0
    OS : WINNT, win
    Thanks.

    ( i am quite Noobie at making plugins, so im sorry if im annoyin anyone. )
  2. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    Code:
    main: TheDeibo\ServerLoveExt\main
    Your class Name is Main, not main. Change it to
    Code:
    main: thedeibo\ServerLoveExt\Main
  3. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    Your post didn't help in any way.
    GmWM likes this.
  4. GmWM
    Offline

    GmWM Active Member Plugin Developer

    Joined:
    Sep 8, 2013
    Posts:
    181
    Plugins:
    3
    He should learn that too. Lol
  5. TheDeibo
    Offline

    TheDeibo Notable Member

    Joined:
    Sep 8, 2014
    Posts:
    693
    Minecraft User:
    TheDeibo
    Lol. I am trying to jumpstart my php life. ( Run before I walk)
  6. TheDeibo
    Offline

    TheDeibo Notable Member

    Joined:
    Sep 8, 2014
    Posts:
    693
    Minecraft User:
    TheDeibo
    I am still getting this error. I cant seem to find the problem, or fix it.
    Any idead?

    My Full PHP
    Code:
    <?php
    namespace thedeibo\ServerLoveExt;
    use pocketmine\command\Command;
    use pocketmine\command\ComamndSender;
    class Main extends PluginBase{
      public function onEnable(){
        // $this->getServer()->getPluginManager()->registerEvents($this, $this);
      }
        public function onCommand(CommandSender $sender, Command $command, $label, array $args){
        $commandName = $command->getName();
        if($commandName === "serverlove"){
          $sender->sendMessage("Hi!");
          return true;
        }
        return false;
      }
    }
    
    PLUGIN.YML
    Code:
    name: ServerLoveExt
    version: 1.0.0
    author: TheDeibo
    api: 1.12.0
    main: thedeibo\ServerLoveExt\Main
    commands:
        serverlove:
            description: Gives all importent infomation about the plugin.
            usage: /serverlove Gives all important infomation about the plugin.    
    permissions:
        serverloveext.serverlove:
            default: true
            description: Allows user to use /serverlove
    
    ERROR
    PocketMine-MP Crash Dump Fri Oct 16 15:41:07 UTC 2015

    Error: Class thedeibo\ServerLoveExt\PluginBase not found
    File: /src/spl/BaseClassLoader
    Line: 144
    Type: notice

    THIS CRASH WAS CAUSED BY A PLUGIN

    Code:
    [135]
    [136] if(\method_exists($name, "onClassLoaded") and (new ReflectionClass($name))->getMethod("onClassLoaded")->isStatic()){
    [137] $name::eek:nClassLoaded();
    [138] }
    [139]
    [140] $this->classes[] = $name;
    [141]
    [142] return \true;
    [143] }elseif($this->getParent() === \null){
    [144] throw new ClassNotFoundException("Class $name not found");
    [145] }
    [146]
    [147] return \false;
    [148] }
    [149]
    [150] /**
    [151] * Returns the path for the class, if any
    [152] *
    [153] * @param string $name
    [154] *

    Backtrace:
    #0 /NvBau4OrvT0_.phar/src/thedeibo/ServerLoveExt/Main(5): spl_autoload_call(string thedeibo\ServerLoveExt\PluginBase)
    #1 /src/spl/BaseClassLoader(128): include(string phar://C:/Users/TheDeibo/Documents/PocketMine-MP/plugins/NvBau4OrvT0_.phar/src/thedeibo/ServerLoveExt/Main.php)
    #2 (): BaseClassLoader->loadClass(string thedeibo\ServerLoveExt\Main)
    #3 (): spl_autoload_call(string thedeibo\ServerLoveExt\Main)
    #4 /src/pocketmine/plugin/PharPluginLoader(64): class_exists(string thedeibo\ServerLoveExt\Main, boolean 1)
    #5 /src/pocketmine/plugin/PluginManager(152): pocketmine\plugin\PharPluginLoader->loadPlugin(string C:\Users\TheDeibo\Documents\PocketMine-MP\plugins\NvBau4OrvT0_.phar)
    #6 /src/pocketmine/plugin/PluginManager(296): pocketmine\plugin\PluginManager->loadPlugin(string C:\Users\TheDeibo\Documents\PocketMine-MP\plugins\NvBau4OrvT0_.phar, array Array())
    #7 /src/pocketmine/Server__32bit(1633): pocketmine\plugin\PluginManager->loadPlugins(string C:\Users\TheDeibo\Documents\PocketMine-MP\plugins\)
    #8 /src/pocketmine/PocketMine(464): pocketmine\Server->__construct(pocketmine\CompatibleClassLoader object, pocketmine\utils\MainLogger object, string phar://C:/Users/TheDeibo/Documents/PocketMine-MP/PocketMine-MP.phar/, string C:\Users\TheDeibo\Documents\PocketMine-MP\, string C:\Users\TheDeibo\Documents\PocketMine-MP\plugins\)
    #9 (1): require(string phar://C:/Users/TheDeibo/Documents/PocketMine-MP/PocketMine-MP.phar/src/pocketmine/PocketMine.php)

    PocketMine-MP version: 1.6dev #35 [Protocol 34; API 1.13.0]
    Git commit: 0000000000000000000000000000000000000000
    uname -a: Windows NT TheDeibo-PC 6.2 build 9200 (Windows 8 Business Edition) i586
    PHP Version: 5.6.6
    Zend version: 2.6.0
    OS : WINNT, win

    Loaded plugins:
    AdminJoin 1.3.0 by for API(s) 1.0.0
    Alias 1.2.0 by ZacHack for API(s) 1.12.0
    BanItem 2.1 by LDX for API(s) 1.0.0
    Broadcaster 1.16 by EvolSoft for API(s) 1.12.0
    ClearLagg 1.1.0 by LegendOfMCPE for API(s) 1.0.0
    CustomAlerts 1.5 by EvolSoft for API(s) 1.12.0
    iProtector 2.0 by LDX for API(s) 1.6.0
    KeepInventory 1.2.0 by boybook for API(s) 1.0.0
    MSpawns 1.5 by EvolSoft for API(s) 1.11.0
  7. GmWM
    Offline

    GmWM Active Member Plugin Developer

    Joined:
    Sep 8, 2013
    Posts:
    181
    Plugins:
    3
    Use this code:
    PHP:
    <?php
    namespace thedeibo\ServerLoveExt;
    use 
    pocketmine\plugin\PluginBase//Don't forget in the future.
    use pocketmine\command\Command;
    use 
    pocketmine\command\ComamndSender;
    class 
    Main extends PluginBase{
      public function 
    onEnable(){
        
    // $this->getServer()->getPluginManager()->registerEvents($this, $this);
      
    }
        public function 
    onCommand(CommandSender $senderCommand $command$label, array $args){
        
    $commandName $command->getName();
        if(
    $commandName === "serverlove"){
          
    $sender->sendMessage("Hi!");
          return 
    true;
        }
        return 
    false;
      }
    }
  8. TheDeibo
    Offline

    TheDeibo Notable Member

    Joined:
    Sep 8, 2014
    Posts:
    693
    Minecraft User:
    TheDeibo
    its just flooded my console with
    Fatal error: Declaration of thedeibo\ServerLoveExt\Main::eek:nCommand() must be compatible with pocketmine\command\CommandExecutor::eek:nCommand(pocketmine\command\CommandSender $sender, pocketmine\command\Command $command, $label, array $args) in phar://C:/Users/Damian/Documents/PocketMine-MP/plugins/kyl2OW8pxKI_.phar/src/thedeibo/ServerLoveExt/Main.php on line 0

    Call Stack:
    0.0490 434808 1. {main}() C:\Users\Damian\Documents\PocketMine-MP\PocketMine-MP.phar:0
    0.0539 429712 2. require('phar://C:/Users/Damian/Documents/PocketMine-MP/PocketMine-MP.phar/src/pocketmine/PocketMine.php') C:\Users\Damian\Documents\PocketMine-MP\PocketMine-MP.phar:1
    0.3157 570232 3. pocketmine\Server->__construct() phar://C:/Users/Damian/Documents/PocketMine-MP/PocketMine-MP.phar/src/pocketmine/PocketMine.php:464
    2.0812 14135352 4. pocketmine\plugin\PluginManager->loadPlugins() phar://C:/Users/Damian/Documents/PocketMine-MP/PocketMine-MP.phar/src/pocketmine/Server__32bit.php:1633
    2.2442 14640560 5. pocketmine\plugin\PluginManager->loadPlugin() phar://C:/Users/Damian/Documents/PocketMine-MP/PocketMine-MP.phar/src/pocketmine/plugin/PluginManager.php:296
    2.2452 14643080 6. pocketmine\plugin\PharPluginLoader->loadPlugin() phar://C:/Users/Damian/Documents/PocketMine-MP/PocketMine-MP.phar/src/pocketmine/plugin/PluginManager.php:152
    2.2477 14645600 7. class_exists() phar://C:/Users/Damian/Documents/PocketMine-MP/PocketMine-MP.phar/src/pocketmine/plugin/PharPluginLoader.php:64
    2.2477 14645792 8. spl_autoload_call() phar://C:/Users/Damian/Documents/PocketMine-MP/PocketMine-MP.phar/src/pocketmine/plugin/PharPluginLoader.php:64
    2.2477 14645832 9. BaseClassLoader->loadClass() phar://C:/Users/Damian/Documents/PocketMine-MP/PocketMine-MP.phar/src/pocketmine/plugin/PharPluginLoader.php:64
  9. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    Learn how to read Error codes.
    PHP:
    <?php
    namespace thedeibo\ServerLoveExt;
    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\command\Command;
    use 
    pocketmine\command\CommandSender;
    class 
    Main extends PluginBase{
      public function 
    onEnable(){
        
    // $this->getServer()->getPluginManager()->registerEvents($this, $this);
      
    }
        public function 
    onCommand(CommandSender $senderCommand $command$label, array $args){
        
    $commandName $command->getName();
        if(
    $commandName === "serverlove"){
          
    $sender->sendMessage("Hi!");
          return 
    true;
        }
        return 
    false;
      }
    CavinMiana likes this.
  10. TheDeibo
    Offline

    TheDeibo Notable Member

    Joined:
    Sep 8, 2014
    Posts:
    693
    Minecraft User:
    TheDeibo
    I completly agree, I do. I am trying to run before I crawl :p thats how I learn.

    anyway, thanks CraftYourBukkit, its successful.
  11. GmWM
    Offline

    GmWM Active Member Plugin Developer

    Joined:
    Sep 8, 2013
    Posts:
    181
    Plugins:
    3
    I just can't see any difference between my code and yours.
    Is there anything changed? :|
  12. TheDeibo
    Offline

    TheDeibo Notable Member

    Joined:
    Sep 8, 2014
    Posts:
    693
    Minecraft User:
    TheDeibo
    Maybe the formatting fixed it? its just i copied the code you used, and it worked. :p
  13. GmWM
    Offline

    GmWM Active Member Plugin Developer

    Joined:
    Sep 8, 2013
    Posts:
    181
    Plugins:
    3
    Hm...wierd.
    Anyway. Hope I solved your problem. :D
  14. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    PHP:
    use pocketmine\command\ComamndSender;
    Both of you had that typo in there^^
  15. GmWM
    Offline

    GmWM Active Member Plugin Developer

    Joined:
    Sep 8, 2013
    Posts:
    181
    Plugins:
    3
    Oh. I understand. lol :D
  16. TheDeibo
    Offline

    TheDeibo Notable Member

    Joined:
    Sep 8, 2014
    Posts:
    693
    Minecraft User:
    TheDeibo
    You did!!!!! :D Thanks for the help
    you were actually very helpful
  17. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    It is always a good idea to do
    PHP:
    if(strtolower($commandName) == "serverlove")
    Legoboy0215 likes this.
  18. TheDeibo
    Offline

    TheDeibo Notable Member

    Joined:
    Sep 8, 2014
    Posts:
    693
    Minecraft User:
    TheDeibo
    What would that do differently to the original then?
  19. MCPEPIG
    Offline

    MCPEPIG Notable Member

    Joined:
    Jun 22, 2014
    Posts:
    349
    Minecraft User:
    MCPEPIG
    It will be case insensitive
  20. jojoe77777
    Offline

    jojoe77777 Notable Member Plugin Developer

    Joined:
    May 28, 2015
    Posts:
    653
    Plugins:
    1
    Minecraft User:
    jojoe77777
    And all of you guys forgot to uncomment the register events line :rolleyes:
    HotFireyDeath likes this.

Share This Page

Advertisement