Multiple Files In the SRC

Discussion in 'Development' started by Junkdude, Nov 13, 2016.

  1. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,143
    GitHub:
    Thunder33345
    well the getserver method is not implimetnted
     
  2. Junkdude

    Junkdude Zombie

    Messages:
    346
    GitHub:
    JunkDaCoder
    How do i implement it?
     
  3. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,143
    GitHub:
    Thunder33345
    you can't but you can try use Server::getInstance()
    or add a constructor(hope you still remember oop) that need you to pass server instance
    the constructor will set a local var to the server
    like this (sorry no indention on my ipad rn)
    PHP:
    class example {
    private 
    $server
    public function __construct(Server $server){
    $this->server $server;
    }
    }
    $this->getRegisterEvent(new example($this->getServer()),$this)
     
  4. Junkdude

    Junkdude Zombie

    Messages:
    346
    GitHub:
    JunkDaCoder
    Say I put the command into the Main file, will i have to do this
     
  5. Junkdude

    Junkdude Zombie

    Messages:
    346
    GitHub:
    JunkDaCoder
    Kk, so i just merged everything, and I get this error
    Warning: Uncaught ClassNotFoundException: Class CustomEnchantments\Command not found in phar://C:/Users/Conner/Desktop/GensisyTestServer/Genisys.phar/src/spl/BaseClassLoader.php:144
    Stack trace:
    #0 [internal function]: BaseClassLoader->loadClass('CustomEnchantme...')
    #1 C:\Users\Conner\Desktop\GensisyTestServer\plugins\CustomEnchantments\src\CustomEnchantments\Main.php(31): spl_autoload_call('CustomEnchantme...')
    #2 phar://C:/Users/Conner/Desktop/GensisyTestServer/Genisys.phar/src/spl/BaseClassLoader.php(128): include('C:\\Users\\Conner...')
    #3 [internal function]: BaseClassLoader->loadClass('CustomEnchantme...')
    #4 [internal function]: spl_autoload_call('CustomEnchantme...')
    #5 phar://C:/Users/Conner/Desktop/GensisyTestServer/plugins/DevTools_v1.10.0.phar/src/FolderPluginLoader/FolderPluginLoader.php(64): class_exists('CustomEnchantme...', true)
    #6 phar://C:/Users/Conner/Desktop/GensisyTestServer/Genisys.phar/src/pocketmine/plugin/PluginManager.php(152): FolderPluginLoader\FolderPluginLoader->loadPlugin('C:\\Users\\C in phar://C:/Users/Conner/Desktop/GensisyTestServer/Genisys.phar/src/spl/BaseClassLoader.php on line 144

    Fatal error: Declaration of CustomEnchantments\Main::eek:nCommand(pocketmine\command\CommandSender $sender, CustomEnchantments\Command $cmd, $label, array $args) must be compatible with pocketmine\command\CommandExecutor::eek:nCommand(pocketmine\command\CommandSender $sender, pocketmine\command\Command $command, $label, array $args) in C:\Users\Conner\Desktop\GensisyTestServer\plugins\CustomEnchantments\src\CustomEnchantments\Main.php on line 31
     
  6. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,143
    GitHub:
    Thunder33345
    don't extend/implimet command executor
    remove calls to other files since they are removed
     
  7. Junkdude

    Junkdude Zombie

    Messages:
    346
    GitHub:
    JunkDaCoder
    fixed, thank you all
     
  8. InspectorGadget

    InspectorGadget Zombie Pigman

    Messages:
    463
    GitHub:
    InspectorGadget
    For commands do, for better commands like /CE Zara buy. This would work
    PHP:
    public function onCommand(CommandSender $senderCommand $command //bla) {
    if (!isset($args[0])) {
    $sender->sendMessage("CustomEnchantments");
    }
    switch (
    strtolower($args[0])){
    case:
    //bla
    return;
    break;
     
    Last edited: Nov 14, 2016
  9. InspectorGadget

    InspectorGadget Zombie Pigman

    Messages:
    463
    GitHub:
    InspectorGadget
    PHP:
    Server::getInstance()
    isn't encouraged by PM.
     
    SOFe likes this.
  10. Sandertv

    Sandertv Zombie Pigman Poggit Reviewer

    Messages:
    786
    GitHub:
    Sandertv
    Am I supposed... to be mentioned or something?
     
  11. InspectorGadget

    InspectorGadget Zombie Pigman

    Messages:
    463
    GitHub:
    InspectorGadget
    Nope, why do u think so?
     
  12. Sandertv

    Sandertv Zombie Pigman Poggit Reviewer

    Messages:
    786
    GitHub:
    Sandertv
    Your code block is telling me a different story :p
     
  13. InspectorGadget

    InspectorGadget Zombie Pigman

    Messages:
    463
    GitHub:
    InspectorGadget
    Which one do u mean?
     
  14. Sandertv

    Sandertv Zombie Pigman Poggit Reviewer

    Messages:
    786
    GitHub:
    Sandertv
    This one, it tells my name twice :p
     
  15. InspectorGadget

    InspectorGadget Zombie Pigman

    Messages:
    463
    GitHub:
    InspectorGadget
    Lmao, it does but I do mean another "bla" not this "blabla"
    Btw, good joke <3
     
  16. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,973
    GitHub:
    sof3
    Well... why break after return?
     
  17. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,143
    GitHub:
    Thunder33345
    ok cool now i request you to post your latest code
    we surely can do some minor optimization
     
  18. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,143
    GitHub:
    Thunder33345
    that is something i will have to read on my free time
     
  19. InspectorGadget

    InspectorGadget Zombie Pigman

    Messages:
    463
    GitHub:
    InspectorGadget
    The full code has Default: after break, that's why..
     
  20. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,973
    GitHub:
    sof3
    It's dead code. Any code after return statements will not be executed, unless you have labels like `case:`, `default:` or goto labels. You don't need the break line at all. `return` already does the trick of exiting the function.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.