Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/justblender/gominet
Minecraft protocol and server library
https://github.com/justblender/gominet
Last synced: 13 days ago
JSON representation
Minecraft protocol and server library
- Host: GitHub
- URL: https://github.com/justblender/gominet
- Owner: justblender
- License: mit
- Archived: true
- Created: 2017-08-07T23:41:11.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-08-24T08:48:06.000Z (over 7 years ago)
- Last Synced: 2024-06-20T01:32:30.842Z (6 months ago)
- Language: Go
- Homepage:
- Size: 34.2 KB
- Stars: 6
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome - justblender/gominet - Minecraft protocol and server library (Go)
- awesome - justblender/gominet - Minecraft protocol and server library (Go)
README
# GoMiNET
Basic Minecraft server library written on Golang and based on Taylor Blau's project over at [ttaylorr/minecraft](https://github.com/ttaylorr/minecraft).## Installation:
`go get -t github.com/justblender/gominet`## Creating your own basic server:
```go
package mainimport (
"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
}
```