Skip to content
This repository has been archived by the owner on Apr 22, 2020. It is now read-only.

justblender/gominet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GoMiNET

Basic Minecraft server library written on Golang and based on Taylor Blau's project over at ttaylorr/minecraft.

Installation:

go get -t github.com/justblender/gominet

Creating your own basic server:

package main

import (
	"fmt"
	"errors"
	"reflect"
	"github.com/justblender/gominet"
	"github.com/justblender/gominet/protocol"
	"github.com/justblender/gominet/protocol/packet"
)

func main() {
	server := gominet.NewServer("127.0.0.1", 25565, handlePackets)
	server.ListenAndServe()
}

func handlePackets(conn *protocol.Connection, holder packet.Holder) error {
	switch conn.State {
	case protocol.Handshake:
		handshake, ok := holder.(packet.Handshake)
		if !ok {
			return errors.New(fmt.Sprintf("Expected handshake, received: %s", reflect.TypeOf(holder)))
		}

		conn.Protocol = uint16(handshake.ProtocolVersion)
		conn.State = protocol.State(uint8(handshake.NextState))

	default:
		// Do your own thing here now
		return errors.New("Not implemented yet")
	}

	return nil
}

About

Minecraft protocol and server library

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages