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

Are you able to do 2 events in one plugin

Comments in 'Plugin Development' started by jerlegoman, Jun 17, 2014.

  1. jerlegoman
    Offline

    jerlegoman Active Member

    Joined:
    Dec 10, 2013
    Posts:
    120
    Minecraft User:
    jeremy647
    Hi my name is Jerlegoman I am in the middle of developing a plugin I call Clock And Compass Plus+
    and I want to know if you are allowed to put two events in one plugin. Thanks!:)
  2. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Why not?
  3. swagboy47
    Offline

    swagboy47 Active Member

    Joined:
    Jun 10, 2014
    Posts:
    445
    Minecraft User:
    swagking
    Sure you can.in fact you can put as much as you want
  4. jerlegoman
    Offline

    jerlegoman Active Member

    Joined:
    Dec 10, 2013
    Posts:
    120
    Minecraft User:
    jeremy647
    Do you do the name of the array eventhandle
  5. swagboy47
    Offline

    swagboy47 Active Member

    Joined:
    Jun 10, 2014
    Posts:
    445
    Minecraft User:
    swagking
    Doesn't matter.
  6. swagboy47
    Offline

    swagboy47 Active Member

    Joined:
    Jun 10, 2014
    Posts:
    445
    Minecraft User:
    swagking
    But make sure it's the same as the public/private function for it
    Last edited: Jun 17, 2014
  7. swagboy47
    Offline

    swagboy47 Active Member

    Joined:
    Jun 10, 2014
    Posts:
    445
    Minecraft User:
    swagking
    And you put
    Case player.action
    Bla bla bla
    Break;
    Case player.block.touch
    Bla bla bla
    Break;
  8. swagboy47
    Offline

    swagboy47 Active Member

    Joined:
    Jun 10, 2014
    Posts:
    445
    Minecraft User:
    swagking
    I would give a better example but I am using my phone
  9. DA_Swagnemite
    Offline

    DA_Swagnemite Notable Member Plugin Developer

    Joined:
    Nov 17, 2013
    Posts:
    386
    Plugins:
    7
    Minecraft User:
    DA_SWAGNEMITE
    For "multi-events" make the multiple event handlers in the __construct function (if on api 12) and in the EventHandler function do:
    PHP:
    public function EventHandler($data$event){
        switch(
    $event){
            case 
    "player.join":
                
    $data->sendChat("Welcome to this server!");
            break;

            case 
    "player.quit":
                
    $this->api->server->broadcast("Aww... Someone left...");
             break;
        }
    }
    (NOTE: I havent worked with API 12 in awhile and forget some of it)[/PHP]
    Last edited by a moderator: Jun 17, 2014
    args likes this.
  10. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Edited by a moderator?

    And please don't function EventHandler() please...
    Comedyman937 likes this.
  11. args
    Offline

    args New Member

    Joined:
    Jun 14, 2014
    Posts:
    47
    Minecraft User:
    args
    Do you mean because the name is used for other stuff? Like he should write public function playerConnections() or something like that instead?
  12. iamadpond
    Offline

    iamadpond Banned

    Joined:
    Aug 24, 2013
    Posts:
    191
    Minecraft User:
    iamadpond
    I've noticed you said you were developing for the OLD API, why not invest some time and learn the new one as the the old api will soon become depreciated.

    Edit: 1 1 1 1 100 post!
    Last edited: Jun 17, 2014
    Darunia18 and Comedyman937 like this.
  13. args
    Offline

    args New Member

    Joined:
    Jun 14, 2014
    Posts:
    47
    Minecraft User:
    args
    Yeah I gotta agree, the new API is so much nicer and I think even easier to work with once learned. Once there are some mor eplugins out it will be especially easy to learn :D
  14. swagboy47
    Offline

    swagboy47 Active Member

    Joined:
    Jun 10, 2014
    Posts:
    445
    Minecraft User:
    swagking
    I know the new API but I am going to steel code in the old one until it takes it's last breath
  15. swagboy47
    Offline

    swagboy47 Active Member

    Joined:
    Jun 10, 2014
    Posts:
    445
    Minecraft User:
    swagking
    Once you learn the old one its hard to learn the new one
  16. args
    Offline

    args New Member

    Joined:
    Jun 14, 2014
    Posts:
    47
    Minecraft User:
    args
    I think that's true, but I also think the new one is easier to learn than the old one was :)
  17. iamadpond
    Offline

    iamadpond Banned

    Joined:
    Aug 24, 2013
    Posts:
    191
    Minecraft User:
    iamadpond
    Not really ,take the transition from HTML4 to HTML5 . I learned the new syntax in some time. It's all about how much time you put into learning the new one.
  18. Dinokiller
    Offline

    Dinokiller Notable Member

    Joined:
    Sep 22, 2013
    Posts:
    376
    Minecraft User:
    Dinokiller_
    No, because PocketMine plugins are object orientated. It's common practice to use "camel-case" in method names. For this you have lowercase for the first world and upper case at the start of every other word. So instead of EventHandler you would use eventHandler. It will work without this, but it would be like writing a sentence with no punctuation.
    PEMapModder, args and Comedyman937 like this.
  19. args
    Offline

    args New Member

    Joined:
    Jun 14, 2014
    Posts:
    47
    Minecraft User:
    args
    Oh lol ty. I didn't even notice the syntax.
  20. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Don't cap the first one...

Share This Page

Advertisement