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

Interesting event priority.

Comments in 'Plugin Development' started by Legoboy0215, Feb 7, 2016.

  1. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    I recently noticed this piece of code in the PocketMine source:

    PHP:
    if(preg_match("/^[\t ]*\\* @priority[\t ]{1,}([a-zA-Z]{1,})/m", (string) $method->getDocComment(), $matches) > 0){
        
    $matches[1] = strtoupper($matches[1]);
        if(
    defined(EventPriority::class . "::" $matches[1])){
            
    $priority constant(EventPriority::class . "::" $matches[1]);
        }
    }
    I did not know PHP could parse doc comments. How would I use priorities? So 5 gets executed first or what?
  2. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder

Share This Page

Advertisement