palworldrcon

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

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

Go to latest
Published: Feb 18, 2024 License: MIT Imports: 9 Imported by: 0

README

palworld-rcon

GitHub Build Go Report Card Go Reference

Install

go get github.com/invliD/palworld-rcon

Usage

package main

import (
	"fmt"
	"log"

	palworldrcon "github.com/invliD/palworld-rcon"
)

func main() {
	client := palworldrcon.NewClient("127.0.0.1:25575", "password")
	defer client.Close()

	info, err := client.Info()
	if err != nil {
		log.Fatal(err)
	}

	fmt.Printf("Connected to server '%s' running version %s!\n", info.ServerName, info.Version)
}

License

MIT License, see LICENSE

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client represents a client to a Palword RCON server. Only use NewClient to instantiate a client.

Available commands are documented at https://tech.palworldgame.com/settings-and-operation/commands#command-list. Not all commands listed there are applicable from RCON.

func NewClient

func NewClient(address string, password string) *Client

NewClient creates a new Client with the given address and password. Note that this function does not attempt to connect to the RCON server, so the password is not validated at this time. Instead, the connection is established on-demand when a method on the Client is called.

func (*Client) BanPlayer

func (r *Client) BanPlayer(steamID uint64) error

KickPlayer instructs the server to ban the player with the given Steam ID from the server. The player must be online to be banned.

func (*Client) Broadcast

func (r *Client) Broadcast(message string) error

Broadcast displays the given message to all online players.

func (*Client) Close

func (r *Client) Close() error

Close closes the connection to the RCON server. Calling any other method after closing will reopen the connection.

func (*Client) DoExit

func (r *Client) DoExit() error

DoExit instructs the server to immediately exit.

func (*Client) Info

func (r *Client) Info() (*ServerInfo, error)

Info returns information about the server.

func (*Client) KickPlayer

func (r *Client) KickPlayer(steamID uint64) error

KickPlayer instructs the server to kick the player with the given Steam ID.

func (*Client) Save

func (r *Client) Save() error

Save instructs the server to save the world to disk.

func (*Client) ShowPlayers

func (r *Client) ShowPlayers() ([]Player, error)

ShowPlayers returns a list of all players that are currently online.

func (*Client) Shutdown

func (r *Client) Shutdown(seconds int) error

Shutdown instructs the server to shut down after the given number of seconds.

func (*Client) ShutdownWithMessage

func (r *Client) ShutdownWithMessage(seconds int, message string) error

ShutdownWithMessage instructs the server to shut down after the given number of seconds. The message will be displayed to all online players.

type Player

type Player struct {
	Name      string
	PlayerUID uint64
	SteamID   uint64
}

Player is the representation of a single player.

type ServerInfo

type ServerInfo struct {
	ServerName string
	Version    string
}

ServerInfo represents the information about the server returned by Client.Info().

Jump to

Keyboard shortcuts

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