Example #1
0
func main() {
	err := gamerules.LoadGameRules(*blockDefs, *itemDefs, *recipeDefs, *furnaceDefs, *userDefs, *groupDefs)

	if err != nil {
		fmt.Fprintf(os.Stdout, "Error loading definitions: %v\n", err)
		os.Exit(1)
	}

	fmt.Println("PASS")
}
Example #2
0
func main() {
	var err error

	flag.Usage = usage
	flag.Parse()

	if flag.NArg() != 1 {
		flag.Usage()
		os.Exit(1)
	}

	err = gamerules.LoadGameRules(*blockDefs, *itemDefs, *recipeDefs, *furnaceDefs, *userDefs, *groupDefs)
	if err != nil {
		log.Print("Error loading game rules: ", err)
		os.Exit(1)
	}

	worldPath := flag.Arg(0)
	fi, err := os.Stat(worldPath)
	if err != nil {
		log.Printf("Could not load world from directory %v: %v", worldPath, err)
		log.Printf("Creating a new world in directory %v", worldPath)
		err = worldstore.CreateWorld(worldPath)
	}
	if err != nil {
		log.Printf("Error creating new world: %v", err)
	} else {
		fi, err = os.Stat(worldPath)
	}

	if fi == nil || !fi.IsDir() {
		log.Printf("Error loading world %v: Not a directory", worldPath)
		os.Exit(1)
	}

	listener, err := net.Listen("tcp", *addr)
	if err != nil {
		log.Fatal(err)
	}

	game, err := chunkymonkey.NewGame(worldPath, listener, *serverDesc, *maintenanceMsg, *maxPlayerCount)
	if err != nil {
		log.Fatal(err)
	}

	err = startHttpServer(*httpAddr)
	if err != nil {
		log.Fatal(err)
	}

	log.Printf("Server started on %s", *httpAddr)
	game.Serve()
}