config

package module
v0.0.0-...-ccec2f6 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2021 License: MIT Imports: 7 Imported by: 0

README

go-minecraft-config

CI codecov

This repository contains simple golang structs for Minecraft config files.

This supports loading: server.properties, banned-ips.json, banned-players.json, ops.json, and whitelist.json.

Documentation

Index

Constants

View Source
const (
	// MinecraftConfigFile maps to `server.properties`
	MinecraftConfigFile string = "server.properties"
	// MinecraftDenyIPFile maps to `banned-ips.json`
	MinecraftDenyIPFile string = "banned-ips.json"
	// MinecraftDenyUserFile maps to `banned-players.json`
	MinecraftDenyUserFile string = "banned-players.json"
	// MinecraftOperatorUserFile maps to `ops.json`
	MinecraftOperatorUserFile string = "ops.json"
	// MinecraftAllowUserFile maps to `whitelist.json`
	MinecraftAllowUserFile string = "whitelist.json"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AllowUserList

type AllowUserList []User

AllowUserList represents a list of users allowed to join a minecraft server. IE: The list of users from `whitelist.json`

func LoadAllowUserList

func LoadAllowUserList(dir string) (AllowUserList, error)

LoadAllowUserList loads `whitelist.json`

type Config

type Config struct {
	AllowFlight                    bool   `properties:"allow-flight,default=false" json:"allow_flight" firestore:"allow_flight"`
	AllowNether                    bool   `properties:"allow-nether,default=true" json:"allow_nether" firestore:"allow_nether"`
	BroadcastConsoleToOps          bool   `properties:"broadcast-console-to-ops,default=true" json:"broadcast_console_to_ops" firestore:"broadcast_console_to_ops"`
	BroadcastRconToOps             bool   `properties:"broadcast-rcon-to-ops,default=true" json:"broadcast_rcon_to_ops" firestore:"broadcast_rcon_to_ops"`
	Difficulty                     string `properties:"difficulty,default=easy" json:"difficulty" firestore:"difficulty"`
	EnableCommandBlock             bool   `properties:"enable-command-block,default=false" json:"enable_command_block" firestore:"enable_command_block"`
	EnableJmxMonitoring            bool   `properties:"enable-jmx-monitoring,default=false" json:"enable_jmx_monitoring" firestore:"enable_jmx_monitoring"`
	EnableRcon                     bool   `properties:"enable-rcon,default=false" json:"enable_rcon" firestore:"enable_rcon"`
	SyncChunkWrites                bool   `properties:"sync-chunk-writes,default=true" json:"sync_chunk_writes" firestore:"sync_chunk_writes"`
	EnableStatus                   bool   `properties:"enable-status,default=true" json:"enable_status" firestore:"enable_status"`
	EnableQuery                    bool   `properties:"enable-query,default=false" json:"enable_query" firestore:"enable_query"`
	EntityBroadcastRangePercentage int    `` /* 145-byte string literal not displayed */
	ForceGamemode                  bool   `properties:"force-gamemode,default=false" json:"force_gamemode" firestore:"force_gamemode"`
	Gamemode                       string `properties:"gamemode,default=survival" json:"gamemode" firestore:"gamemode"`
	GenerateStructures             bool   `properties:"generate-structures,default=true" json:"generate_structures" firestore:"generate_structures"`
	GeneratorSettings              string `properties:"generator-settings,default=" json:"generator_settings" firestore:"generator_settings"`
	Hardcore                       bool   `properties:"hardcore,default=false" json:"hardcore" firestore:"hardcore"`
	LevelName                      string `properties:"level-name,default=world" json:"level_name" firestore:"level_name"`
	LevelSeed                      string `properties:"level-seed,default=" json:"level_seed" firestore:"level_seed"`
	LevelType                      string `properties:"level-type,default=default" json:"level_type" firestore:"level_type"`
	MaxBuildHeight                 int    `properties:"max-build-height,default=256" json:"max_build_height" firestore:"max_build_height"`
	MaxPlayers                     int    `properties:"max-players,default=20" json:"max_players" firestore:"max_players"`
	MaxTickTime                    int    `properties:"max-tick-time,default=60000" json:"max_tick_time" firestore:"max_tick_time"`
	MaxWorldSize                   int    `properties:"max-world-size,default=29999984" json:"max_world_size" firestore:"max_world_size"`
	MotD                           string `properties:"motd,default=A Minecraft Server" json:"motd" firestore:"motd"`
	NetworkCompressionThreshold    int    `` /* 133-byte string literal not displayed */
	OnlineMode                     bool   `properties:"online-mode,default=true" json:"online_mode" firestore:"online_mode"`
	OpPermissionLevel              int    `properties:"op-permission-level,default=4" json:"op_permission_level" firestore:"op_permission_level"`
	PlayerIdleTimeout              int    `properties:"player-idle-timeout,default=0" json:"player_idle_timeout" firestore:"player_idle_timeout"`
	PreventProxyConnections        bool   `properties:"prevent-proxy-connections,default=false" json:"prevent_proxy_connections" firestore:"prevent_proxy_connections"`
	PvP                            bool   `properties:"pvp,default=true" json:"pvp" firestore:"pvp"`
	QueryPort                      int    `properties:"query.port,default=25565" json:"query_port" firestore:"query_port"`
	RateLimit                      int    `properties:"rate-limit,default=0" json:"rate_limit" firestore:"rate_limit"`
	RconPassword                   string `properties:"rcon.password,default=" json:"rcon_password" firestore:"rcon_password"`
	RconPort                       int    `properties:"rcon.port,default=25575" json:"rcon_port" firestore:"rcon_port"`
	ResourcePack                   string `properties:"resource-pack,default=" json:"resource_pack" firestore:"resource_pack"`
	ResourcePackSHA1               string `properties:"resource-pack-sha1,default=" json:"resource_pack_sha1" firestore:"resource_pack_sha1"`
	RequireResourcePack            bool   `properties:"require-resource-pack,default=false" json:"require_resource_pack" firestore:"require_resource_pack"`
	ServerIP                       string `properties:"server-ip,default=" json:"server_ip" firestore:"server_ip"`
	ServerPort                     int    `properties:"server-port,default=25565" json:"server_port" firestore:"server_port"`
	SnooperEnabled                 bool   `properties:"snooper-enabled,default=true" json:"snooper_enabled" firestore:"snooper_enabled"`
	SpawnAnimals                   bool   `properties:"spawn-animals,default=true" json:"spawn_animals" firestore:"spawn_animals"`
	SpawnMonsters                  bool   `properties:"spawn-monsters,default=true" json:"spawn_monsters" firestore:"spawn_monsters"`
	SpawnNpcs                      bool   `properties:"spawn-npcs,default=true" json:"spawn_npcs" firestore:"spawn_npcs"`
	ViewDistance                   int    `properties:"view-distance,default=10" json:"view_distance" firestore:"view_distance"`
	WhiteList                      bool   `properties:"white-list,default=false" json:"white_list" firestore:"white_list"`
	EnforceWhitelist               bool   `properties:"enforce-whitelist,default=false" json:"enforce_whitelist" firestore:"enforce_whitelist"`
}

Config represents the Minecraft server config

func LoadConfig

func LoadConfig(dir string) (*Config, error)

LoadConfig loads server config from the provided directory

type Deny

type Deny struct {
	// Created is when the ban was created
	Created MinecraftTime `json:"created" firestore:"created"`
	// Source represents where the ban originated from. IE: user or console
	Source string `json:"source" firestore:"source"`
	// Expires represents when the ban expires, usually "forever"
	Expires MinecraftTime `json:"expires" firestore:"expires"`
	// Reason represents why a ban was created
	Reason string `json:"reason" firestore:"reason"`
}

Deny represents why a `User` or `net.IP` was denied access to a server.

type DenyIP

type DenyIP struct {
	// IP is the `net.IP` that was banned, typically IPv4
	IP net.IP `json:"ip" firestore:"ip"`
	Deny
}

DenyIP represents why a `net.IP` was denied access to a server.

type DenyIPList

type DenyIPList []DenyIP

DenyIPList represents a list of `net.IP` that were banned from a server and why. IE: The list of IPs from `banned-ips.json`

func LoadDenyIPList

func LoadDenyIPList(dir string) (DenyIPList, error)

LoadDenyIPList loads `banned-ips.json`

type DenyUser

type DenyUser struct {
	User
	Deny
}

DenyUser represents why a `User` was denied access to a server.

type DenyUserList

type DenyUserList []DenyUser

DenyUserList represents a list of `User` that were banned from a server and why. IE: The list of Users from `banned-ips.json`

func LoadDenyUserList

func LoadDenyUserList(dir string) (DenyUserList, error)

LoadDenyUserList loads `banned-players.json`

type MinecraftTime

type MinecraftTime struct {
	time.Time
}

MinecraftTime is a JSON representation of time in Minecraft. "forever" is decoded as a zero time and vice versa..

func (MinecraftTime) MarshalJSON

func (mt MinecraftTime) MarshalJSON() ([]byte, error)

MarshalJSON encodes a MinecrafTime into JSON

func (*MinecraftTime) UnmarshalJSON

func (mt *MinecraftTime) UnmarshalJSON(byteJSON []byte) (err error)

UnmarshalJSON decodes a json byte array into a MinecrafTime

type OperatorUser

type OperatorUser struct {
	User

	// Level represents the operator level which determines what they can modify
	Level               int  `json:"level" firestore:"level"`
	BypassesPlayerLimit bool `json:"bypassesPlayerLimit" firestore:"bypasses_player_limit"`
}

OperatorUser represents an operator in the OperatorUserList

type OperatorUserList

type OperatorUserList []OperatorUser

OperatorUserList represents a list of operators of a minecraft server IE: The list of operators from `ops.json`

func LoadOperatorUserList

func LoadOperatorUserList(dir string) (OperatorUserList, error)

LoadOperatorUserList loads `pos.json`

type User

type User struct {
	// Name is the display name of the minecraft user
	Name string `json:"name" firestore:"name"`
	// UUID is the unique identifier of the minecraft user
	UUID string `json:"uuid" firestore:"uuid"`
}

User represents a minecraft user

Jump to

Keyboard shortcuts

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