Kick clients when resource pack rejected (#5440)
This commit is contained in:
parent
16f3355bbb
commit
21ec3ebe26
@ -65,6 +65,7 @@ NiLSPACE (formerly STR_Warrior)
|
||||
npresley0506
|
||||
p-mcgowan
|
||||
Persson-dev
|
||||
plan1231
|
||||
pokechu22
|
||||
ProjectBM
|
||||
pwnOrbitals
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -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");
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user