server

package
v0.0.0-...-b33f08c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 9, 2021 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Java8  string
	Java16 string
)

Java version commands

View Source
var DEFAULTSERVERPROPERTIES = `` /* 1004-byte string literal not displayed */

DEFAULTSERVERPROPERTIES is the default server properties file

View Source
var HOSTNAME = "localhost"

HOSTNAME is where we store the flag value

View Source
var Servers = make(map[string]Server)

Servers is the global list of managed servers

Functions

func AuthorizeMiddleware

func AuthorizeMiddleware() gin.HandlerFunc

AuthorizeMiddleware middleware

func Hostname

func Hostname(flagValue string)

Hostname takes the flag value and calculates the best attempt at a hostname

func LoadServers

func LoadServers() error

LoadServers loads servers from disk and caches results

func NextAvailablePort

func NextAvailablePort() int

NextAvailablePort will return the next available server port one should loadServers() before this to ensure accurate data

func ServersWebView

func ServersWebView(playerName string) map[string]WebView

ServersWebView is a web view of a list of servers

func ServersWithPlayer

func ServersWithPlayer(playerName string) map[string]Server

ServersWithPlayer returns a list of servers the Op owns or is an op on

Types

type Op

type Op struct {
	UUID              string `json:"uuid"`
	Name              string `json:"name"`
	Level             int8   `json:"level"`
	BypassPlayerLimit bool   `json:"bypassesPlayerLimit"`
}

Op is the structure of an op within the ops.json file

type Permission

type Permission struct {
	Name           string `json:"name"`
	Allowed        bool   `json:"allowed"`
	RequireRunning bool   `json:"reqRunning"`
}

type Permissions

type Permissions map[string]Permission

func PermissionsOp

func PermissionsOp() Permissions

func PermissionsOwner

func PermissionsOwner() Permissions

func PermissionsPlayer

func PermissionsPlayer() Permissions

type Properties

type Properties map[string]string

Properties is a hash of key:value pairs contained in the server.properties file

type Server

type Server struct {
	AutoStart bool       `json:"autostart"`
	Deleted   bool       `json:"deleted"`
	Flavor    string     `json:"flavor"`
	MaxMem    string     `json:"maxmem"`
	MinMem    string     `json:"minmem"`
	Name      string     `json:"name"`
	Owner     string     `json:"owner"`
	Props     Properties `json:"properties"`
	Release   string     `json:"release"`
	UUID      string     `json:"uuid"`
}

Server is an instance of a server, tracked during runtime

func LoadServer

func LoadServer(serverDir string) (Server, error)

LoadServer creates a new instance of Server from an existing serverdir

func NewServer

func NewServer(owner string, formData forms.NewServer, port int) (Server, error)

NewServer creates a new instance of Server, and sets up the serverdir

func (*Server) AddOpOffline

func (s *Server) AddOpOffline(opName, uuid string, force bool) error

AddOpOffline will add a user as an op the force option is to ignore errors from loading the ops.json file like happens when one doesn't exist.

func (*Server) AddOpOnline

func (s *Server) AddOpOnline(opName string) error

AddOpOnline will add a user as an op using rcon

func (*Server) AddWhitelistOffline

func (s *Server) AddWhitelistOffline(playerName, uuid string, force bool) error

AddWhitelistOffline will instruct the server to whitelist a player

func (*Server) AddWhitelistOnline

func (s *Server) AddWhitelistOnline(playerName string) error

AddWhitelistOnline will instruct the server to whitelist a player

func (*Server) Backup

func (s *Server) Backup(message string) error

Backup will instruct the server to perform a save-all operation

func (*Server) Day

func (s *Server) Day() error

Day will instruct the server to set the time to day

func (*Server) Delete

func (s *Server) Delete() error

Delete is WAY scary!!!

func (*Server) DownloadJar

func (s *Server) DownloadJar() error

DownloadJar downloads the server jar

func (*Server) IsOp

func (s *Server) IsOp(player string) bool

IsOp returns if a given player name is found in the list of server ops

func (*Server) IsOwner

func (s *Server) IsOwner(player string) bool

IsOwner returns if a given player name the server owner

func (*Server) IsRunning

func (s *Server) IsRunning() bool

IsRunning attempts to determine if the server is running by checking rcon connect

func (*Server) LoadOps

func (s *Server) LoadOps() ([]Op, error)

LoadOps will read in the contents of the server's ops.json file

func (*Server) LoadWhitelist

func (s *Server) LoadWhitelist() ([]WLPlayer, error)

LoadWhitelist will read in the contents of the server's ops.json file

func (*Server) Ops

func (s *Server) Ops() []Op

Ops will return a list of ops contained in the server's ops.json file (a zero-error equivalent of LoadOps)

func (*Server) PlayerIsOp

func (s *Server) PlayerIsOp(playerName string) bool

PlayerIsOp checks if the given player name is in the lits of ops

func (*Server) PlayerIsWhitelisted

func (s *Server) PlayerIsWhitelisted(playerName string) bool

PlayerIsWhitelisted checks if the given player name is in the lits of ops

func (*Server) PlayerPerms

func (s *Server) PlayerPerms(playerName string) Permissions

PlayerPerms returns the server permissions of the given player name

func (*Server) Players

func (s *Server) Players() []string

Players gets player list

func (*Server) RefreshProperties

func (s *Server) RefreshProperties() error

RefreshProperties reads in the server.properties values

func (*Server) Regen

func (s *Server) Regen() error

Regen generates a new world

func (*Server) Save

func (s *Server) Save() error

Save will instruct the server to perform a save-all operation

func (*Server) SaveManagedJSON

func (s *Server) SaveManagedJSON() error

SaveManagedJSON writes the server config to disk

func (*Server) SaveOps

func (s *Server) SaveOps(ops []Op) error

SaveOps will save the provided ops to the server's ops.json (overwrites the contents)

func (*Server) SaveProps

func (s *Server) SaveProps() error

SaveProps will save the properties into server.properties

func (*Server) SaveWhitelist

func (s *Server) SaveWhitelist(wlps []WLPlayer) error

SaveWhitelist will save the provided ops to the server's ops.json (overwrites the contents)

func (*Server) ServerDir

func (s *Server) ServerDir() string

ServerDir builds the path to the server storage dir

func (Server) Start

func (s Server) Start() error

Start starts the server (expected to be run as a goroutine)

func (*Server) Stop

func (s *Server) Stop(delay int) error

Stop broadcasts a message to the server then stops it after the delay

func (*Server) Upgrade

func (s *Server) Upgrade() error

func (*Server) WeatherClear

func (s *Server) WeatherClear() error

WeatherClear will instruct the server to perform a save-all operation

func (*Server) WebView

func (s *Server) WebView(playerName string) WebView

WebView returns a web-formatted view of the server

func (*Server) Whitelist

func (s *Server) Whitelist() string

Whitelist returns the list of whitelisted players

func (*Server) WhitelistEnabled

func (s *Server) WhitelistEnabled() bool

WhitelistEnabled will instruct the server to whitelist a player

type WLPlayer

type WLPlayer struct {
	UUID string `json:"uuid"`
	Name string `json:"name"`
}

WLPlayer is the structure of a payer within the whitelist.json file

type WebView

type WebView struct {
	AutoStart        bool        `json:"autostart"`
	Flavor           string      `json:"flavor"`
	GameMode         string      `json:"gamemode"`
	Hardcore         string      `json:"hardcore"`
	MOTD             string      `json:"motd"`
	Name             string      `json:"name"`
	Ops              string      `json:"ops"`
	Owner            string      `json:"owner"`
	Permissions      Permissions `json:"perms"`
	Players          []string    `json:"players"`
	Port             string      `json:"port"`
	PVP              string      `json:"pvp"`
	Release          string      `json:"release"`
	Running          bool        `json:"running"`
	Seed             string      `json:"seed"`
	UUID             string      `json:"uuid"`
	WhiteList        string      `json:"whitelist"`
	WhiteListEnabled bool        `json:"whitelistenabled"`
	WorldType        string      `json:"worldtype"`
}

WebView web view of a server instance

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL