A modification-free API for Minecraft utilizing log parsing
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

42 lines
555 B

package main
import (
"bufio"
"os"
"strings"
)
func loadServerConfig(configPath string) (map[string]string, error) {
f, err := os.Open(configPath)
if err != nil {
return nil, err
}
defer f.Close()
scanner := bufio.NewScanner(f)
var text string
var m []string
ret := make(map[string]string)
for scanner.Scan() {
text = scanner.Text()
if text[0] == '#' {
continue
}
m = configRegexp.FindStringSubmatch(text)
if m == nil {
continue
}
ret[strings.TrimSpace(m[1])] = strings.TrimSpace(m[2])
}
return ret, nil
}