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

Solved API 2.0.0/ plugin creation

Comments in 'Plugin Development' started by StarProgamGamer, Mar 12, 2016.

  1. StarProgamGamer
    Offline

    StarProgamGamer New Member

    Joined:
    Mar 12, 2016
    Posts:
    11
    Minecraft User:
    coolgamer564
    Is it because of the new API or is this just an error:
    E_COMPILE_ERROR - Declaration of Plugin\Plugin\plugin: OnCommand(pocketmine\command\CommandSender $sender, pocketmine\command\Command $command, $label, $args) must be compatible with pocketmine\command\CommandExecutor: OnCommand(pocketmine\command\CommandSender $sender, pocketmine\command\Command $command, $label, array $args).
    Any suggestions?
    I attached the code for my PHP file.

    Attached Files:

    Last edited: Mar 12, 2016
  2. Vaivez66
    Offline

    Vaivez66 Notable Member Plugin Developer

    Joined:
    Jun 10, 2015
    Posts:
    402
    Plugins:
    2
    Is that an error of your plugin, or what?
  3. StarProgamGamer
    Offline

    StarProgamGamer New Member

    Joined:
    Mar 12, 2016
    Posts:
    11
    Minecraft User:
    coolgamer564
    @Vaivez66 Yes, it is my plugin. But I don't know the reason. I've attached the code
  4. Vaivez66
    Offline

    Vaivez66 Notable Member Plugin Developer

    Joined:
    Jun 10, 2015
    Posts:
    402
    Plugins:
    2
    It should be
    PHP:
    public function onCommand(CommandSender $senderCommand $command$label, array $args)
    not
    PHP:
    public function onCommand(CommandSender $senderCommand $command$label$args)
    applqpak and PEMapModder like this.
  5. StarProgamGamer
    Offline

    StarProgamGamer New Member

    Joined:
    Mar 12, 2016
    Posts:
    11
    Minecraft User:
    coolgamer564
    okay thx. I will close this if it works
  6. StarProgamGamer
    Offline

    StarProgamGamer New Member

    Joined:
    Mar 12, 2016
    Posts:
    11
    Minecraft User:
    coolgamer564
    @Vaivez66 nope still not working
    PHP:
    <?php

    namespace Plugin\Plugin;

    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\command\CommandSender;
    use 
    pocketmine\command\Command;

    class 
    plugin extends PluginBase {
        public function 
    onEnable() {
          
        }
        public function 
    onDisable() {
          
        }
        public function 
    onCommand(CommandSender $senderCommand $cmd$label, array $args) {
             if(
    strtolower($cmd->getName(test))){
                       
    $sender->sendMessage("Hello ".$sender->getName()."!");
             }  
        }
    }
    Last edited: Mar 12, 2016
  7. StarProgamGamer
    Offline

    StarProgamGamer New Member

    Joined:
    Mar 12, 2016
    Posts:
    11
    Minecraft User:
    coolgamer564
    this is the structure:
    Plugin
    src
    Plugin
    plugin.php
    plugin.yml
  8. StarProgamGamer
    Offline

    StarProgamGamer New Member

    Joined:
    Mar 12, 2016
    Posts:
    11
    Minecraft User:
    coolgamer564
    Plugin
    -----src
    -------Plugin
    -----------Plugin.php
    -----plugin.yml
  9. StarProgamGamer
    Offline

    StarProgamGamer New Member

    Joined:
    Mar 12, 2016
    Posts:
    11
    Minecraft User:
    coolgamer564
    and this the plugin.yaml file:
    Code:
    name: Plugin
    version: 0.9.0.1
    author: coolgamer564
    main: Plugin
    commands:
    test:
      description: says hi
      usage: "Usage: /test"
      permission: plugin.command.test
    permissions:
    plugin.command.test:
      description: "Says hi to the user"
      default: true
    api: 2.0.0
  10. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Still the same error? The message should be different. Post it.

    Also, as a good practice, don't make plugins with generic namespaces like "Plugin".
    applqpak and Vaivez66 like this.
  11. Vaivez66
    Offline

    Vaivez66 Notable Member Plugin Developer

    Joined:
    Jun 10, 2015
    Posts:
    402
    Plugins:
    2
    PHP:
    if(strtolower($cmd->getName()) == 'test')
    ankitmaharjan252 and applqpak like this.
  12. StarProgamGamer
    Offline

    StarProgamGamer New Member

    Joined:
    Mar 12, 2016
    Posts:
    11
    Minecraft User:
    coolgamer564
    Code:
    ClassNotFoundException: "Class Plugin not found" (EXCEPTION) in "/src/spl/BaseClassLoader" at line 144
    [11:35:03] [Server thread/DEBUG]: #0 (): spl_autoload_call(string Plugin)
    [11:35:03] [Server thread/DEBUG]: #1 /DevTools.phar/src/FolderPluginLoader/FolderPluginLoader(64): class_exists(string Plugin, boolean 1)
    [11:35:03] [Server thread/DEBUG]: #2 /src/pocketmine/plugin/PluginManager(152): FolderPluginLoader\FolderPluginLoader->loadPlugin(string PocketMine-MP\plugins\Plugin)
    [11:35:03] [Server thread/DEBUG]: #3 /src/pocketmine/plugin/PluginManager(293): pocketmine\plugin\PluginManager->loadPlugin(string PocketMine-MP\plugins\Plugin, array Array())
    [11:35:03] [Server thread/DEBUG]: #4 /DevTools.phar/src/DevTools/DevTools(45): pocketmine\plugin\PluginManager->loadPlugins(string PocketMine-MP\plugins\, array Array())
    [11:35:03] [Server thread/DEBUG]: #5 /src/pocketmine/plugin/PluginBase(86): DevTools\DevTools->onEnable(boolean)
    [11:35:03] [Server thread/DEBUG]: #6 /src/pocketmine/plugin/PharPluginLoader(123): pocketmine\plugin\PluginBase->setEnabled(boolean 1)
    [11:35:03] [Server thread/DEBUG]: #7 /src/pocketmine/plugin/PluginManager(562): pocketmine\plugin\PharPluginLoader->enablePlugin(DevTools\DevTools object)
    [11:35:03] [Server thread/DEBUG]: #8 /src/pocketmine/Server__64bit(1846): pocketmine\plugin\PluginManager->enablePlugin(DevTools\DevTools object)
    [11:35:03] [Server thread/DEBUG]: #9 /src/pocketmine/Server__64bit(1832): pocketmine\Server->enablePlugin(DevTools\DevTools object)
    [11:35:03] [Server thread/DEBUG]: #10 /src/pocketmine/Server__64bit(1586): pocketmine\Server->enablePlugins(integer 0)
    [11:35:04] [Server thread/DEBUG]: #11 /src/pocketmine/PocketMine(464): pocketmine\Server->__construct(pocketmine\CompatibleClassLoader object, pocketmine\utils\MainLogger object, string phar://PocketMine-MP\PocketMine-MP.phar/, string PocketMine-MP\, string PocketMine-MP\plugins\)
    [11:35:04] [Server thread/DEBUG]: #12 (1): require_once(string phar:///PocketMine-MP/PocketMine-MP.phar/src/pocketmine/PocketMine.php)
    @Vaivez66 Here's the error
    Last edited: Mar 12, 2016
  13. StarProgamGamer
    Offline

    StarProgamGamer New Member

    Joined:
    Mar 12, 2016
    Posts:
    11
    Minecraft User:
    coolgamer564
    @Vaivez66
    Code:
    [12:09:17] [Server thread/CRITICAL]: ClassNotFoundException: "Class Plugin not found" (EXCEPTION) in "/src/spl/BaseClassLoader" at line 144
    [12:09:17] [Server thread/DEBUG]: #0 (): spl_autoload_call(string Plugin)
    [12:09:17] [Server thread/DEBUG]: #1 /DevTools.phar/src/FolderPluginLoader/FolderPluginLoader(64): class_exists(string Plugin, boolean 1)
    [12:09:17] [Server thread/DEBUG]: #2 /src/pocketmine/plugin/PluginManager(152): FolderPluginLoader\FolderPluginLoader->loadPlugin(string PocketMine-MP\plugins\Plugin)
    [12:09:17] [Server thread/DEBUG]: #3 /src/pocketmine/plugin/PluginManager(293): pocketmine\plugin\PluginManager->loadPlugin(string PocketMine-MP\plugins\Plugin, array Array())
    [12:09:17] [Server thread/DEBUG]: #4 /DevTools.phar/src/DevTools/DevTools(45): pocketmine\plugin\PluginManager->loadPlugins(string PocketMine-MP\plugins\, array Array())
    [12:09:17] [Server thread/DEBUG]: #5 /src/pocketmine/plugin/PluginBase(86): DevTools\DevTools->onEnable(boolean)
    [12:09:17] [Server thread/DEBUG]: #6 /src/pocketmine/plugin/PharPluginLoader(123): pocketmine\plugin\PluginBase->setEnabled(boolean 1)
    [12:09:17] [Server thread/DEBUG]: #7 /src/pocketmine/plugin/PluginManager(562): pocketmine\plugin\PharPluginLoader->enablePlugin(DevTools\DevTools object)
    [12:09:17] [Server thread/DEBUG]: #8 /src/pocketmine/Server__64bit(1846): pocketmine\plugin\PluginManager->enablePlugin(DevTools\DevTools object)
    [12:09:17] [Server thread/DEBUG]: #9 /src/pocketmine/Server__64bit(1832): pocketmine\Server->enablePlugin(DevTools\DevTools object)
    [12:09:17] [Server thread/DEBUG]: #10 /src/pocketmine/Server__64bit(1586): pocketmine\Server->enablePlugins(integer 0)
    [12:09:17] [Server thread/DEBUG]: #11 /src/pocketmine/PocketMine(464): pocketmine\Server->__construct(pocketmine\CompatibleClassLoader object, pocketmine\utils\MainLogger object, string phar://Desktop\PocketMine-MP\PocketMine-MP.phar/, string Desktop\PocketMine-MP\, string PocketMine-MP\plugins\)
    [12:09:17] [Server thread/DEBUG]: #12 (1): require_once(string phar://PocketMine-MP/PocketMine-MP.phar/src/pocketmine/PocketMine.php)
    @Vaivez66 can u read this?
    @Vaivez66 !!
    Last edited: Mar 12, 2016
  14. applqpak
    Offline

    applqpak Active Member Plugin Developer

    Joined:
    Dec 16, 2015
    Posts:
    284
    Plugins:
    1
    Minecraft User:
    applqpak
    Please use pmt.mcpe.me website. In my opinion it gives MUCH better errors reading etc
  15. StarProgamGamer
    Offline

    StarProgamGamer New Member

    Joined:
    Mar 12, 2016
    Posts:
    11
    Minecraft User:
    coolgamer564
    its ok ive fixed it now :)
  16. Vaivez66
    Offline

    Vaivez66 Notable Member Plugin Developer

    Joined:
    Jun 10, 2015
    Posts:
    402
    Plugins:
    2
    Sorry, it didn't send alert to me...
    StarProgamGamer likes this.
  17. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Actually, if you guys don't have monospace phobia, it isn't really that hard to understand CLI errors :p
    StarProgamGamer and applqpak like this.
  18. applqpak
    Offline

    applqpak Active Member Plugin Developer

    Joined:
    Dec 16, 2015
    Posts:
    284
    Plugins:
    1
    Minecraft User:
    applqpak
    Lol, still your website is best. :p
    StarProgamGamer likes this.
  19. CallumDouglas
    Offline

    CallumDouglas New Member

    Joined:
    Jan 20, 2016
    Posts:
    32
    Minecraft User:
    Callum9966
    Can you send a plugin download?
  20. StarProgamGamer
    Offline

    StarProgamGamer New Member

    Joined:
    Mar 12, 2016
    Posts:
    11
    Minecraft User:
    coolgamer564

Share This Page

Advertisement