-
Notifications
You must be signed in to change notification settings - Fork 0
Getting Started
Paweł edited this page Feb 25, 2024
·
5 revisions
In this page the imports used are:
import (
mc "github.com/pawelk1337/mcsrv"
mcsh "github.com/pawelk1337/mcsrv/shared"
mcevents "github.com/pawelk1337/mcsrv/wrapper/events"
)
To make a simple server, you can use:
serverConfig := mcsh.ServerConfig{
AcceptEula: true,
Path: "./server",
Engine: mcsh.PAPER,
Version: "latest", // Use the latest version
Build: "latest",
Port: "25565",
Host: "127.0.0.1",
InitialHeapSize: 2048, // 2 GB
MaxHeapSize: 2048, // 2 GB
}
logFunc := func(line string, tick int) {
print(line) // line already includes \n
}
// Automaticly Downloads, Makes the directory, Creates the wrapper
// logFunc can be nil
server, err := mc.NewServer(&serverConfig, logFunc)
To start the server, you can use:
// Start the server
go srv.Start()
// Make sure that the server is stopped safely
defer srv.Stop()
// Wait for the server to start
<-srv.Wrapper.Loaded()
...
server, err := mc.ImportServer("./server")
...