Kick clients when resource pack rejected (#5440)

This commit is contained in:
plan1231 2022-10-28 09:54:02 -04:00 committed by GitHub
parent 16f3355bbb
commit 21ec3ebe26
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 23 additions and 0 deletions

View File

@ -65,6 +65,7 @@ NiLSPACE (formerly STR_Warrior)
npresley0506
p-mcgowan
Persson-dev
plan1231
pokechu22
ProjectBM
pwnOrbitals

View File

@ -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)

View File

@ -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);

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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");

View File

@ -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;