minecraft

package
v0.0.0-...-3667945 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2019 License: MIT Imports: 7 Imported by: 0

README

Minecraft Plugin

This plugin uses the RCON protocol to collect statistics from a scoreboard on a Minecraft server.

To enable RCON on the minecraft server, add this to your server configuration in the server.properties file:

enable-rcon=true
rcon.password=<your password>
rcon.port=<1-65535>

To create a new scoreboard objective called jump on a minecraft server tracking the stat.jump criteria, run this command in the Minecraft console:

/scoreboard objectives add jump stat.jump

Stats are collected with the following RCON command, issued by the plugin:

/scoreboard players list *

Configuration:
[[inputs.minecraft]]
   # server address for minecraft
   server = "localhost"
   # port for RCON
   port = "25575"
   # password RCON for mincraft server
   password = "replace_me"
Measurements & Fields:

This plugin uses only one measurement, titled minecraft

  • The field name is the scoreboard objective name.

  • The field value is the count of the scoreboard objective

  • minecraft

    • <objective_name> (integer, count)
Tags:
  • The minecraft measurement:
    • server: the Minecraft RCON server
    • player: the Minecraft player
Sample Queries:

Get the number of jumps per player in the last hour:

SELECT SPREAD("jump") FROM "minecraft" WHERE time > now() - 1h GROUP BY "player"
Example Output:
$ telegraf --input-filter minecraft --test
* Plugin: inputs.minecraft, Collection 1
> minecraft,player=notch,server=127.0.0.1:25575 jumps=178i 1498261397000000000
> minecraft,player=dinnerbone,server=127.0.0.1:25575 deaths=1i,jumps=1999i,cow_kills=1i 1498261397000000000
> minecraft,player=jeb,server=127.0.0.1:25575 d_pickaxe=1i,damage_dealt=80i,d_sword=2i,hunger=20i,health=20i,kills=1i,level=33i,jumps=264i,armor=15i 1498261397000000000

Documentation

Index

Constants

View Source
const (
	// NoMatches is a sentinel value returned when there are no statistics defined on the
	//minecraft server
	NoMatches = `All matches failed`
	// ScoreboardPlayerList is the command to see all player statistics
	ScoreboardPlayerList = `scoreboard players list *`
)

Variables

This section is empty.

Functions

func ParsePlayerName

func ParsePlayerName(input string) (string, error)

ParsePlayerName takes an input string from rcon, to parse the player.

Types

type Client

type Client interface {
	Gather(producer RCONClientProducer) ([]string, error)
}

Client is an interface for a client which gathers data from a minecraft server

type Minecraft

type Minecraft struct {
	Server   string
	Port     string
	Password string
	// contains filtered or unexported fields
}

Minecraft represents a connection to a minecraft server

func (*Minecraft) Description

func (s *Minecraft) Description() string

Description gives a brief description.

func (*Minecraft) Gather

func (s *Minecraft) Gather(acc telegraf.Accumulator) error

Gather uses the RCON protocol to collect player and scoreboard stats from a minecraft server. var hasClient bool = false

func (*Minecraft) SampleConfig

func (s *Minecraft) SampleConfig() string

SampleConfig returns our sampleConfig.

type RCON

type RCON struct {
	Server   string
	Port     string
	Password string
	// contains filtered or unexported fields
}

RCON represents a RCON server connection

func NewRCON

func NewRCON(server, port, password string) (*RCON, error)

NewRCON creates a new RCON

func (*RCON) Gather

func (r *RCON) Gather(producer RCONClientProducer) ([]string, error)

Gather receives all player scoreboard information and returns it per player.

type RCONClient

type RCONClient interface {
	Authorize(password string) (*rcon.Packet, error)
	Execute(command string) (*rcon.Packet, error)
}

RCONClient is a representation of RCON command authorizaiton and exectution

type RCONClientProducer

type RCONClientProducer interface {
	// contains filtered or unexported methods
}

RCONClientProducer is an interface which defines how a new client will be produced in the event of a network disconnect. It exists mainly for testing purposes

type Score

type Score struct {
	Name  string
	Value int
}

Score is an individual tracked scoreboard stat.

func ParseScoreboard

func ParseScoreboard(input string) ([]Score, error)

ParseScoreboard takes an input string from rcon, to parse scoreboard stats.

Directories

Path Synopsis
internal
rcon
Package rcon implements the communication protocol for communicating with RCON servers.
Package rcon implements the communication protocol for communicating with RCON servers.

Jump to

Keyboard shortcuts

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