Cuberite
A lightweight, fast and extensible game server for Minecraft
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
ProtocolPalettes Class Reference

Loads the protocol-specific palettes on startup and provides them to the individual protocol instances when they are created. More...

#include <ProtocolPalettes.h>

Collaboration diagram for ProtocolPalettes:
Collaboration graph
[legend]

Classes

struct  Palettes
 Container for all palettes for a single protocol. More...
 

Public Member Functions

std::shared_ptr< const BlockTypePaletteblockTypePalette (const AString &aProtocolVersion) const
 Returns the BlockTypePalette for the specified protocol. More...
 
void load (const AString &aProtocolFolder)
 Loads all the per-protocol palettes. More...
 
std::vector< AStringprotocolVersions () const
 Returns the version names of all protocols that have been loaded. More...
 

Protected Member Functions

void loadSingleVersion (const AString &aProtocolVersion, const AString &aFolder)
 Loads all the palettes from the specified folder into mPalettes under the aProtocolVersion key. More...
 

Protected Attributes

cCriticalSection mCS
 The CS protecting all members against multithreaded access. More...
 
std::map< AString, PalettesmPalettes
 The map of protocol version -> all its palettes. More...
 

Detailed Description

Loads the protocol-specific palettes on startup and provides them to the individual protocol instances when they are created.

Uses the data in the $/Server/Protocol folder. Each protocol version has a subfolder there, containing possibly multiple palette files. All the files are loaded in sequence (alpha-sorted), into the palette corresponding to the file's extension (*.btp.txt -> BlockTypePalette). Provides thread safety for the data properly.

Definition at line 22 of file ProtocolPalettes.h.

Member Function Documentation

std::shared_ptr< const BlockTypePalette > ProtocolPalettes::blockTypePalette ( const AString aProtocolVersion) const

Returns the BlockTypePalette for the specified protocol.

Returns nullptr if no such palette has been loaded.

Definition at line 26 of file ProtocolPalettes.cpp.

void ProtocolPalettes::load ( const AString aProtocolFolder)

Loads all the per-protocol palettes.

aProtocolFolder is the folder that contains a subfolder for each protocol version; each subfolder contains the protocol-specific palettes (as in $/Server/Protocol) If a protocol version is already loaded, yet present in the folder, the newly loaded data is merged into the current data. Always succeeds (even when there are no palettes).

Definition at line 9 of file ProtocolPalettes.cpp.

void ProtocolPalettes::loadSingleVersion ( const AString aProtocolVersion,
const AString aFolder 
)
protected

Loads all the palettes from the specified folder into mPalettes under the aProtocolVersion key.

Definition at line 57 of file ProtocolPalettes.cpp.

std::vector< AString > ProtocolPalettes::protocolVersions ( ) const

Returns the version names of all protocols that have been loaded.

Definition at line 41 of file ProtocolPalettes.cpp.

Member Data Documentation

cCriticalSection ProtocolPalettes::mCS
mutableprotected

The CS protecting all members against multithreaded access.

Definition at line 55 of file ProtocolPalettes.h.

std::map<AString, Palettes> ProtocolPalettes::mPalettes
protected

The map of protocol version -> all its palettes.

Definition at line 58 of file ProtocolPalettes.h.


The documentation for this class was generated from the following files: