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

Solved Class Main extends PluginBase Help

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

  1. TheDeibo
    Offline

    TheDeibo Notable Member Plugin Developer

    Joined:
    Sep 8, 2014
    Posts:
    692
    Plugins:
    1
    Minecraft User:
    TheDeibo
    Can someone correct this for me
    Code:
    class Main extends PluginBase implements Listener{
        public function onEnable(){
            $this->getServer()->getPluginManager()->registerEvents($this, $this);
            @mkdir($this->getDataFolder());
            $this->nolove = new Config($this->getDataFolder()."nolove.txt", Config::ENUM);
        }
    class Main extends PluginBase implements Listener{
        public function onEnable(){
            $this->getServer()->getPluginManager()->registerEvents($this, $this);
            $this->saveDefaultConfig();
            $this->getLogger()->info(TEXTFORMAT::GOLD . "[--ServerLove--]" .TEXTFORMAT::RED. " --> -->" .TEXTFORMAT::GREEN.  " Yayyy, ServerLove is ready for love on Version 1.0.0!");
        }
    
    Thanks.
  2. TheDeibo
    Offline

    TheDeibo Notable Member Plugin Developer

    Joined:
    Sep 8, 2014
    Posts:
    692
    Plugins:
    1
    Minecraft User:
    TheDeibo
    I am absolutely No good with plugins, but I am attempting to merge parts of plugins together. both
    class Main extends PluginBase implements Listener{
    is needed for the plugin, so is they a way they ban be merged, so they both work together?
  3. zombie_Power
    Offline

    zombie_Power Active Member

    Joined:
    Sep 7, 2015
    Posts:
    239
    Minecraft User:
    Zombie_Power
    Why do you have two classes and two onEnable? Please stop copying
  4. TheDeibo
    Offline

    TheDeibo Notable Member Plugin Developer

    Joined:
    Sep 8, 2014
    Posts:
    692
    Plugins:
    1
    Minecraft User:
    TheDeibo
    I repeat, I am attempting to merge parts of plugins together
    And we are aloud to copy. As long as the License says so.
  5. zombie_Power
    Offline

    zombie_Power Active Member

    Joined:
    Sep 7, 2015
    Posts:
    239
    Minecraft User:
    Zombie_Power
    Firstly, if you want to copy, you should atleast understand the code.
    Secondly, please write some information, what you are trying to do?
  6. TheDeibo
    Offline

    TheDeibo Notable Member Plugin Developer

    Joined:
    Sep 8, 2014
    Posts:
    692
    Plugins:
    1
    Minecraft User:
    TheDeibo
    I just managed to do it. Yayyy i finnished the plugin. ( Its a remake of PokePlayer plugin, with certain other features )
    Code:
    class Main extends PluginBase implements Listener{
        public function onEnable(){
            $this->getServer()->getPluginManager()->registerEvents($this, $this);
            @mkdir($this->getDataFolder());
            $this->nolove = new Config($this->getDataFolder()."nolove.txt", Config::ENUM);
            $this->getServer()->getPluginManager()->registerEvents($this, $this);
            $this->saveDefaultConfig();
            $this->getLogger()->info(TEXTFORMAT::GOLD . "[--ServerLove--]" .TEXTFORMAT::RED. " --> -->" .TEXTFORMAT::GREEN.  " Yayyy, ServerLove is ready for love on Version 1.0.0!");
        }
    
  7. zombie_Power
    Offline

    zombie_Power Active Member

    Joined:
    Sep 7, 2015
    Posts:
    239
    Minecraft User:
    Zombie_Power
    That plugin wont do anything but cause a crash
  8. TheDeibo
    Offline

    TheDeibo Notable Member Plugin Developer

    Joined:
    Sep 8, 2014
    Posts:
    692
    Plugins:
    1
    Minecraft User:
    TheDeibo
    well, worth a try. :p
  9. TheDeibo
    Offline

    TheDeibo Notable Member Plugin Developer

    Joined:
    Sep 8, 2014
    Posts:
    692
    Plugins:
    1
    Minecraft User:
    TheDeibo
    By "That plugin" do you mean my remake, or the original?
  10. zombie_Power
    Offline

    zombie_Power Active Member

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

    class Main extends PluginBase implements Listener{
        public function 
    onEnable(){
            
    $this->getServer()->getPluginManager()->registerEvents($this$this);
            @
    mkdir($this->getDataFolder());
            
    $this->nolove = new Config($this->getDataFolder()."nolove.txt"Config::ENUM);
            
    $this->load($this->getDataFolder()."nolove.txt");
    }
    try this
  11. TheDeibo
    Offline

    TheDeibo Notable Member Plugin Developer

    Joined:
    Sep 8, 2014
    Posts:
    692
    Plugins:
    1
    Minecraft User:
    TheDeibo
    I prefer to have the Console plugin thing on though. :p But its not crashing for me. Ill test it propper soon :p
  12. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    He doesn't know how to code. He is just attempting to merge two plugins together.
  13. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    PHP:
    $this->nolove
    is undefined. If you would try to define it, as you do in your code, it'd give you an error.
    PHP:
    @mkdir($this->getDataFolder())
    in this case is not needed, if you save the default config before defining $this->nolove. Tho, if you want to use it, you should check whether the path is already a direction or not.
    Having
    Code:
    $this->getServer()->registerEvents($this, $this);
    two times will cause an error, also it isn't needed in this code (at the moment). Lastly, the code would be
    PHP:
    class Main extends PluginBase implements Listener{
        private 
    $nolove;
        public function 
    onEnable(){
            
    $this->getServer()->getPluginManager()->registerEvents($this$this);
            
    //if(!is_dir($this->getDataFolder())) mkdir($this->getDataFolder());
            
    $this->saveDefaultConfig();
            
    $this->nolove = new Config($this->getDataFolder()."nolove.txt"Config::ENUM);
            
    $this->getLogger()->info(TEXTFORMAT::GOLD "[--ServerLove--]" .TEXTFORMAT::RED" --> -->" .TEXTFORMAT::GREEN.  " Yayyy, ServerLove is ready for love on Version 1.0.0!");
        }
    @zombie_Power - Why shouldn't $this->getLogger()->info(); work?
  14. zombie_Power
    Offline

    zombie_Power Active Member

    Joined:
    Sep 7, 2015
    Posts:
    239
    Minecraft User:
    Zombie_Power
    Oops :p, didn't see it in his code, and as for "nolove", he also needs to make the "nolove.txt" file
  15. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    Yes, in resources. But other than that, he doesn't have to load it or whatever
  16. TheDeibo
    Offline

    TheDeibo Notable Member Plugin Developer

    Joined:
    Sep 8, 2014
    Posts:
    692
    Plugins:
    1
    Minecraft User:
    TheDeibo
    guys, the code works perfectly. the plugin is fine. ( i havent tested two players yet, but i will soon )
  17. TheDeibo
    Offline

    TheDeibo Notable Member Plugin Developer

    Joined:
    Sep 8, 2014
    Posts:
    692
    Plugins:
    1
    Minecraft User:
    TheDeibo
    at the moment, it works single player
  18. AndrewBit
    Offline

    AndrewBit Notable Member

    Joined:
    Jun 18, 2015
    Posts:
    435
    Minecraft User:
    AndrewBit4
    The owner of Deibo xD Delete the fake counter on your server and learn PHP please :)
  19. TheDeibo
    Offline

    TheDeibo Notable Member Plugin Developer

    Joined:
    Sep 8, 2014
    Posts:
    692
    Plugins:
    1
    Minecraft User:
    TheDeibo
    I am trying to learn PHP, so please don't push that on me. (Rome wasn't built in a day!)
    also, what do you mean by "The owner of Deibo xD Delete the fake counter on your server!
    I am the owner of TheDeiboMC if that's what you mean. The server will be back up in 3-4 days from now, if thats what your thinking of fake counter.
  20. AndrewBit
    Offline

    AndrewBit Notable Member

    Joined:
    Jun 18, 2015
    Posts:
    435
    Minecraft User:
    AndrewBit4
    16.000 players Online on minecraft pocket list, and you have the ip with dottk... Also anybody know your server... Is obviusly that you use a fake counter

Share This Page

Advertisement