public static void WaitNext(YamlScanner sc, string node)
 {
     while (sc.TokenText != node && sc.Token != Token.EndOfStream && sc.Token != Token.Outdent)
     {
         sc.NextToken();
     }
 }
        public static string GetNextToken(YamlScanner sc)
        {
            while (sc.NextToken() != Token.TextContent && sc.TokenText != CrLf && sc.Token != Token.EndOfStream)
            {
            }
            //Thread.Sleep(100);

            return((sc.TokenText != CrLf) ? sc.TokenText : String.Empty);
        }
        //public override void onPlayerPreLogin(Terraria_Server.Events.PlayerLoginEvent Event)
        //{
        //    base.onPlayerPreLogin(Event);
        //}
        public void LoadPerms()
        {
            Token to;
            TextReader re = File.OpenText(permissionsYML);

            sc = new YamlScanner();
            sc.SetSource(re);

            inUsers = false;

            while ((to = sc.NextToken()) != Token.EndOfStream)
            {
                switch (to)
                {
                    case Token.TextContent:
                        {
                            switch (sc.TokenText)
                            {
                                case "info":
                                    {
                                        ProcessInfo();
                                        break;
                                    }
                                case "permissions":
                                    {
                                        ProcessPermissions();
                                        break;
                                    }
                                case "inheritance":
                                    {
                                        ParseInheritance();
                                        break;
                                    }
                                case "groups":
                                    {
                                        if (inUsers)
                                        {
                                            ProcessGroups();
                                        }
                                        break;
                                    }
                                case "users":
                                    {
                                        inUsers = true;
                                        ProcessInheritance();
                                        break;
                                    }
                                default:
                                    break;
                            }
                            break;
                        }
                    case Token.IndentSpaces:
                        {
                            ProcessIndent();
                            break;
                        }
                    case Token.Outdent:
                    case Token.ValueIndicator:
                    case Token.BlockSeqNext:
                    case Token.Comma:
                    case Token.Escape:
                    case Token.InconsistentIndent:
                    case Token.Unexpected:
                    case Token.DoubleQuote:
                    case Token.SingleQuote:
                    case Token.EscapedLineBreak:
                    default:
                        break;
                }
            }
        }
 public void LoadPerms()
 {
     Token to;
     TextReader re = File.OpenText(pluginFolder + Path.DirectorySeparatorChar + "permissions.yml");
     sc = new YamlScanner();
     sc.SetSource(re);
     while ((to = sc.NextToken()) != Token.EndOfStream)
     {
         switch (to)
         {
             //case Token.BeginningOfStream:
             //case Token.BlockMappingBegin:
             //case Token.LeadingWhiteSpace:
             //case Token.PlainScalar:
             //case Token.ImplicitKey:
             //case Token.Newline:
             //case Token.EscapeWhiteSpace:
             //case Token.Directive:
             //case Token.DirectivesEnd:
             //case Token.BlockSeqBegin:
             //case Token.BlockKeyIndicator:
             //case Token.FlowKeyIndicator:
             //case Token.OpenBrace:
             //case Token.CloseBrace:
             //case Token.OpenBracket:
             //case Token.CloseBracket:
             //case Token.PlainEnd:
             //case Token.NoOp:
             //case Token.Comment:
             //case Token.EmptyLine:
             //case Token.Anchor:
             //case Token.Alias:
             //case Token.At:
             //case Token.Backtick:
             //case Token.Tag:
             //case Token.Literal:
             //case Token.Folded:
             //    break;
             case Token.TextContent:
                 {
                     switch (sc.TokenText)
                     {
                         //case "groups":
                         //    {
                         //        while (sc.NextToken() != Token.TextContent)
                         //        {
                         //        }
                         //        currentGroup = new Group(sc.TokenText);
                         //        ProgramLog.Debug.Log("Group name: " + currentGroup.Name);
                         //        break;
                         //    }
                         case "info":
                             {
                                 ProcessInfo();
                                 break;
                             }
                         case "permissions":
                             {
                                 ProcessPermissions();
                                 break;
                             }
                         default:
                             break;
                     }
                     break;
                 }
             case Token.IndentSpaces:
                 {
                     ProcessIndent();
                     break;
                 }
             case Token.Outdent:
             case Token.ValueIndicator:
             case Token.BlockSeqNext:
             case Token.Comma:
             case Token.Escape:
             case Token.InconsistentIndent:
             case Token.Unexpected:
             case Token.DoubleQuote:
             case Token.SingleQuote:
             case Token.EscapedLineBreak:
             default:
                 break;
         }
     }
     //foreach (Group g in groups)
     //{
     //    ProgramLog.Debug.Log("Group info for group " + g.Name + ":");
     //    ProgramLog.Debug.Log("Default: " + g.GroupInfo.Default);
     //    ProgramLog.Debug.Log("Prefix: " + g.GroupInfo.Prefix);
     //    ProgramLog.Debug.Log("Suffix: " + g.GroupInfo.Suffix);
     //    ProgramLog.Debug.Log("Permissions:");
     //    foreach (String p in g.permissions.Keys)
     //    {
     //        bool value;
     //        g.permissions.TryGetValue(p, out value);
     //        ProgramLog.Debug.Log(p + ": " + value);
     //    }
     //}
 }
        public static void LoadPerms(string permissionsYML)
        {
            Token      to;
            TextReader re = File.OpenText(permissionsYML);

            sc = new YamlScanner();
            sc.SetSource(re);

            inUsers = false;

            while ((to = sc.NextToken()) != Token.EndOfStream)
            {
                switch (to)
                {
                case Token.TextContent:
                {
                    switch (sc.TokenText)
                    {
                    case "info":
                    {
                        ProcessInfo();
                        break;
                    }

                    case "permissions":
                    {
                        ProcessPermissions();
                        break;
                    }

                    case "inheritance":
                    {
                        ParseInheritance();
                        break;
                    }

                    case "groups":
                    {
                        if (inUsers)
                        {
                            ProcessGroups();
                        }
                        break;
                    }

                    case "users":
                    {
                        inUsers = true;
                        ProcessInheritance();
                        break;
                    }

                    default:
                        break;
                    }
                    break;
                }

                case Token.IndentSpaces:
                {
                    ProcessIndent();
                    break;
                }

                case Token.Outdent:
                case Token.ValueIndicator:
                case Token.BlockSeqNext:
                case Token.Comma:
                case Token.Escape:
                case Token.InconsistentIndent:
                case Token.Unexpected:
                case Token.DoubleQuote:
                case Token.SingleQuote:
                case Token.EscapedLineBreak:
                default:
                    break;
                }
            }
        }
 public static void WaitNext(YamlScanner sc, string node)
 {
     while (sc.TokenText != node && sc.Token != Token.EndOfStream && sc.Token != Token.Outdent)
         sc.NextToken();
 }
        public static string GetNextToken(YamlScanner sc)
        {
            while (sc.NextToken() != Token.TextContent && sc.TokenText != CrLf && sc.Token != Token.EndOfStream) { }
                //Thread.Sleep(100);

            return (sc.TokenText != CrLf) ? sc.TokenText : String.Empty;
        }