MCPcopy Create free account
hub / github.com/PolyMC/PolyMC / Server

Class Server

launcher/ui/pages/instance/ServersPage.cpp:54–131  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

52static const int COLUMN_COUNT = 2; // 3 , TBD: latency and other nice things.
53
54struct Server
55{
56 // Types
57 enum class AcceptsTextures : int
58 {
59 ASK = 0,
60 ALWAYS = 1,
61 NEVER = 2
62 };
63
64 // Methods
65 Server()
66 {
67 m_name = QObject::tr("Minecraft Server");
68 }
69 Server(const QString & name, const QString & address)
70 {
71 m_name = name;
72 m_address = address;
73 }
74 Server(nbt::tag_compound& server)
75 {
76 std::string addressStr(server["ip"]);
77 m_address = QString::fromUtf8(addressStr.c_str());
78
79 std::string nameStr(server["name"]);
80 m_name = QString::fromUtf8(nameStr.c_str());
81
82 if(server["icon"])
83 {
84 std::string base64str(server["icon"]);
85 m_icon = QByteArray::fromBase64(base64str.c_str());
86 }
87
88 if(server.has_key("acceptTextures", nbt::tag_type::Byte))
89 {
90 bool value = server["acceptTextures"].as<nbt::tag_byte>().get();
91 if(value)
92 {
93 m_acceptsTextures = AcceptsTextures::ALWAYS;
94 }
95 else
96 {
97 m_acceptsTextures = AcceptsTextures::NEVER;
98 }
99 }
100 }
101
102 void serialize(nbt::tag_compound& server)
103 {
104 server.insert("name", m_name.trimmed().toUtf8().toStdString());
105 server.insert("ip", m_address.trimmed().toUtf8().toStdString());
106 if(m_icon.size())
107 {
108 server.insert("icon", m_icon.toBase64().toStdString());
109 }
110 if(m_acceptsTextures != AcceptsTextures::ASK)
111 {

Callers 1

addEmptyRowMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected