Skip to content

A simple library for creating and managing minecraft servers.

License

Notifications You must be signed in to change notification settings

pawelk1337/mcsrv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

McSrv: A simple library for creating and managing minecraft servers

Hey! We have a WIKI!

https://www.codefactor.io/repository/github/pawelk1337/mcsrv

Table of Contents

Features

  • Server Downloading
  • Server Events (e.g on Player join, on Player Death, on Chat...)
  • Sending commands to server
  • Easy server creation
  • Multiple Server Engine Support

Getting started

To download the library download the source and put it in to your project's vendor dir. ({myproj}/vendor/mcsrv) and import it by using "github.com/pawelk1337/mcsrv". Make sure to add ./vendor to your go.work file

To create a simple server:

import (
    mc "github.com/pawelk1337/mcsrv"
    mcsh "github.com/pawelk1337/mcsrv/shared"
)

func main() {
    srv, err := mc.NewServer(&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
    }, log) // log can be nil
    if err != nil {
        panic(err) // Replace with actual error handling
    }

    // Start the server
    go srv.Start()
    println("starting server")
    defer srv.Stop()

    // Wait for the server to start
    <-srv.Wrapper.Loaded()

    // Wait for the server to stop
    <-srv.Wrapper.Stopped()
}

More Examples

Check the examples directory

Recommended projects

  • Gate - High-Performance, Low-Memory, Lightweight, Extensible Minecraft Reverse Proxy with Excellent Multi-Protocol Version Support - Velocity/Bungee Replacement - Ready for dev and large deploy!
  • Minecraft Router - Route Minecraft traffic from a configuration file or api.
  • go-Liter - A proxy for Minecraft that can be extended with JavaScript

TODO

  • Server Downloading
  • Server running and Server Wrapping
  • Make Servers Importable
  • Custom Log Handling
  • Fix wrapper.Loaded()
  • add wrapper.Stopped()
  • Parsing server files (e.g server.properties...)

Contact

You can contact me on discord: pawelk1337 (id: 967830338116153496)

Feel free to contact me about anything i will try my hardest to anwser any of your questions.

About

A simple library for creating and managing minecraft servers.

Resources

License

Stars

Watchers

Forks

Languages