diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ClientHandle.cpp | 13 | ||||
-rw-r--r-- | src/ClientHandle.h | 1 | ||||
-rw-r--r-- | src/Protocol/Protocol_1_10.cpp | 1 | ||||
-rw-r--r-- | src/Protocol/Protocol_1_8.cpp | 2 | ||||
-rw-r--r-- | src/Server.cpp | 1 | ||||
-rw-r--r-- | src/Server.h | 4 |
6 files changed, 22 insertions, 0 deletions
diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 5a2e1d620..7fc678de0 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -1884,6 +1884,19 @@ void cClientHandle::HandleUseItem(bool a_UsedMainHand) +void cClientHandle::HandleResourcePack(UInt8 a_Status) +{ + // Kick player if client declined the resource pack + if ((a_Status == 1) && cRoot::Get()->GetServer()->ShouldRequireResourcePack()) + { + Kick("You must accept the resource pack"); + } +} + + + + + void cClientHandle::HandleRespawn(void) { if (m_Player->GetHealth() > 0) diff --git a/src/ClientHandle.h b/src/ClientHandle.h index c5949b57b..a452d765a 100644 --- a/src/ClientHandle.h +++ b/src/ClientHandle.h @@ -377,6 +377,7 @@ public: // tolua_export void HandlePluginMessage (const AString & a_Channel, ContiguousByteBufferView a_Message); + void HandleResourcePack (UInt8 a_Status); void HandleRespawn (void); void HandleRightClick (Vector3i a_BlockPos, eBlockFace a_BlockFace, Vector3i a_Cursor, bool a_UsedMainHand); void HandleSlotSelected (Int16 a_SlotNum); diff --git a/src/Protocol/Protocol_1_10.cpp b/src/Protocol/Protocol_1_10.cpp index 4f89cf6bd..2e0eb52a7 100644 --- a/src/Protocol/Protocol_1_10.cpp +++ b/src/Protocol/Protocol_1_10.cpp @@ -341,6 +341,7 @@ cProtocol::Version cProtocol_1_10_0::GetProtocolVersion() const void cProtocol_1_10_0::HandlePacketResourcePackStatus(cByteBuffer & a_ByteBuffer) { HANDLE_READ(a_ByteBuffer, ReadBEUInt8, UInt8, Status); + m_Client->HandleResourcePack(Status); } diff --git a/src/Protocol/Protocol_1_8.cpp b/src/Protocol/Protocol_1_8.cpp index cbb13e68e..e949d6116 100644 --- a/src/Protocol/Protocol_1_8.cpp +++ b/src/Protocol/Protocol_1_8.cpp @@ -2595,6 +2595,8 @@ void cProtocol_1_8_0::HandlePacketResourcePackStatus(cByteBuffer & a_ByteBuffer) { HANDLE_READ(a_ByteBuffer, ReadVarUTF8String, AString, Hash); HANDLE_READ(a_ByteBuffer, ReadBEUInt8, UInt8, Status); + + m_Client->HandleResourcePack(Status); } diff --git a/src/Server.cpp b/src/Server.cpp index 880ed6c72..36964d41c 100644 --- a/src/Server.cpp +++ b/src/Server.cpp @@ -157,6 +157,7 @@ bool cServer::InitServer(cSettingsRepositoryInterface & a_Settings, bool a_Shoul m_MaxPlayers = static_cast<size_t>(a_Settings.GetValueSetI("Server", "MaxPlayers", 100)); m_bIsHardcore = a_Settings.GetValueSetB("Server", "HardcoreEnabled", false); m_bAllowMultiLogin = a_Settings.GetValueSetB("Server", "AllowMultiLogin", false); + m_RequireResourcePack = a_Settings.GetValueSetB("Server", "RequireResourcePack", false); m_ResourcePackUrl = a_Settings.GetValueSet("Server", "ResourcePackUrl", ""); m_CustomRedirectUrl = a_Settings.GetValueSet("Server", "CustomRedirectUrl", "https://youtu.be/dQw4w9WgXcQ"); diff --git a/src/Server.h b/src/Server.h index 479fbb865..171d68d48 100644 --- a/src/Server.h +++ b/src/Server.h @@ -94,6 +94,9 @@ public: // tolua_end + /** Returns true if clients must accept resource pack. This is read from the settings. */ + bool ShouldRequireResourcePack(void) { return m_RequireResourcePack; } + const AString & GetResourcePackUrl(void) { return m_ResourcePackUrl; } std::string_view GetCustomRedirectUrl(void) { return m_CustomRedirectUrl; } @@ -223,6 +226,7 @@ private: AString m_FaviconData; size_t m_MaxPlayers; bool m_bIsHardcore; + bool m_RequireResourcePack; AString m_ResourcePackUrl; AString m_CustomRedirectUrl; |