Cuberite
A lightweight, fast and extensible game server for Minecraft
ProtocolPalettes.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "../OSSupport/CriticalSection.h"
4 
5 
6 
7 
8 
9 // fwd:
10 class BlockTypePalette;
11 
12 
13 
14 
15 
23 {
24 public:
25 
32  void load(const AString & aProtocolFolder);
33 
36  std::shared_ptr<const BlockTypePalette> blockTypePalette(const AString & aProtocolVersion) const;
37 
39  std::vector<AString> protocolVersions() const;
40 
41 
42 protected:
43 
45  struct Palettes
46  {
47  std::shared_ptr<BlockTypePalette> mBlockTypePalette;
48  // TODO: ItemTypePalette
49 
50  Palettes();
51  };
52 
53 
56 
58  std::map<AString, Palettes> mPalettes;
59 
60 
62  void loadSingleVersion(const AString & aProtocolVersion, const AString & aFolder);
63 };
Container for all palettes for a single protocol.
std::vector< AString > protocolVersions() const
Returns the version names of all protocols that have been loaded.
cCriticalSection mCS
The CS protecting all members against multithreaded access.
void loadSingleVersion(const AString &aProtocolVersion, const AString &aFolder)
Loads all the palettes from the specified folder into mPalettes under the aProtocolVersion key...
std::map< AString, Palettes > mPalettes
The map of protocol version -> all its palettes.
std::shared_ptr< const BlockTypePalette > blockTypePalette(const AString &aProtocolVersion) const
Returns the BlockTypePalette for the specified protocol.
Holds a palette that maps between block type + state and numbers.
Loads the protocol-specific palettes on startup and provides them to the individual protocol instance...
void load(const AString &aProtocolFolder)
Loads all the per-protocol palettes.
std::string AString
Definition: StringUtils.h:13
std::shared_ptr< BlockTypePalette > mBlockTypePalette