MCPcopy Create free account
hub / github.com/ZeppelinMC/Zeppelin / Start

Method Start

server/server.go:151–195  ·  view source on GitHub ↗
(ts time.Time)

Source from the content-addressed store, hash-verified

149}
150
151func (srv *Server) Start(ts time.Time) {
152 if slices.Index(os.Args, "--no-plugins") == -1 {
153 if runtime.GOOS == "darwin" || runtime.GOOS == "linux" || runtime.GOOS == "freebsd" {
154 log.Infoln("Loading plugins")
155 srv.loadPlugins()
156 }
157 }
158
159 log.Info("Preparing world spawn... ")
160 ow := srv.World.Dimension("minecraft:overworld")
161 var chunks int32
162
163 spawnCX, spawnCZ := srv.World.Data.SpawnX>>4, srv.World.Data.SpawnZ>>4
164 for x := spawnCX - srv.cfg.ViewDistance; x < spawnCX+srv.cfg.ViewDistance; x++ {
165 for z := spawnCZ - srv.cfg.ViewDistance; z < spawnCZ+srv.cfg.ViewDistance; z++ {
166 _, err := ow.GetChunk(x, z)
167 if err == nil {
168 chunks++
169 }
170 }
171 }
172
173 fmt.Printf("cached %d chunks\n\r", chunks)
174
175 srv.timeStart = ts
176 log.Infolnf("Done! (%s)", time.Since(ts))
177 for {
178 conn, err := srv.listener.Accept()
179 if err != nil {
180 if !srv.closed {
181 log.Errorln("Server error: ", err)
182 }
183 <-srv.stopLoop
184 return
185 }
186 if srv.onConnectionIntercept != nil {
187 var stop bool
188 srv.onConnectionIntercept(conn, &stop)
189 if stop {
190 continue
191 }
192 }
193 srv.handleNewConnection(conn)
194 }
195}
196
197func (srv *Server) handleNewConnection(conn *net.Conn) {
198 log.Infolnf("%sPlayer attempting to connect: %s (%s)", log.FormatAddr(srv.cfg.LogIPs, conn.RemoteAddr()), conn.Username(), conn.UUID())

Callers 1

mainFunction · 0.80

Calls 9

loadPluginsMethod · 0.95
handleNewConnectionMethod · 0.95
InfolnFunction · 0.92
InfoFunction · 0.92
InfolnfFunction · 0.92
ErrorlnFunction · 0.92
AcceptMethod · 0.80
DimensionMethod · 0.45
GetChunkMethod · 0.45

Tested by

no test coverage detected