minecraft

package
v0.0.0-...-2a33acd Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2021 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Minecraft

type Minecraft struct {
	WorldManager *world.WorldManager

	Events *event.EventManager
	// contains filtered or unexported fields
}

This is the main minecraft type. Create one of these, and use it to start the server itself

func New

func New(needs_session bool, max_players int, needs_reserve bool, default_world string) *Minecraft

Constructor for Minecraft type. Set needs-session to true if it should create an AWS session. The max players of the server is used when a proxy or lobby server sends a ReservePlayersRequest. If needs_reserve is set to true, it will deny all players sent to this server that have not been 'reserved'. If needs_reserve is set to false, then it will accept all incoming connections. Basically, if needs_reserve is true, then this is a server that is part of a network. If a player wants to join, they will need to be connected from another server. If it is false, then players can connect directly to this server. The default_world is a string name to the default world. This is where players are sent when they first connect.

func (*Minecraft) AwsSession

func (m *Minecraft) AwsSession() *session.Session

Gets the current aws session. Returns nil if false was passed into the constructor for the needs-session value.

func (*Minecraft) FinalizeBlocks

func (m *Minecraft) FinalizeBlocks()

This finalizes all blocks, and allows items to be registered.

func (*Minecraft) FinishLoad

func (m *Minecraft) FinishLoad()

This is the last stage of loading. It will finalize items, and load worlds from disk.

func (*Minecraft) Init

func (m *Minecraft) Init()

This loads all basic event types and vanilla blocks. You must call this before registering anything.

func (*Minecraft) MaxPlayers

func (m *Minecraft) MaxPlayers() int

This returns the maximum number of players allowed to connect at any time.

func (*Minecraft) On

func (m *Minecraft) On(name string, handle interface{}) error

Use this to register events. The string name of the event should be one from the README. The event itself can take any number of parameters, and return either a bool or nothing. If it returns a bool, then it is treated as an "is_cancelled" flag. The arguments must match the ones listed in the README, otherwise you will get errors when the event is called. This will cause the server to panic, but that is for testing, and will be disabled soon.

func (*Minecraft) StartUpdateLoop

func (m *Minecraft) StartUpdateLoop(port string)

This is a blocking call, which starts the grpc server. The port should look like this:

:8483

type Plugin

type Plugin interface {
	OnEnable(minecraft *Minecraft)
	OnDisable()
}

This is never used. This will be removed in the near future. This was setup to be like Spigot's plugin system, but in golang, all plugins are statically linked. So it created these massive plugin files, that just made the server huge. Also the core server does nothing, so I thought there was no point in having it load plugins. Since the core server cannot do much, I though it would be best that people write their own main() funcitons, instead of using the server's main.

type PluginManager

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

func NewPluginManager

func NewPluginManager(minecraft *Minecraft) *PluginManager

func (*PluginManager) DisablePlugins

func (m *PluginManager) DisablePlugins()

func (*PluginManager) EnablePlugins

func (m *PluginManager) EnablePlugins()

func (*PluginManager) LoadPlugins

func (m *PluginManager) LoadPlugins()

Jump to

Keyboard shortcuts

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