public static function listenEvent($event, $callback, $priority = 50, $important = false)
    {
        if (!isset(self::$events[$event])) {
            self::$events[$event] = array();
        }
        
        // while there is an event with the same priority, checks
        // with an higher or lower priority
        while (isset(self::$events[$event][$priority])) {
            $priority += $important ? -1 : 1;
        }
        
        self::$events[$event][$priority] = $callback;
    }