summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorplan1231 <47790831+plan1231@users.noreply.github.com>2022-10-28 15:54:02 +0200
committerGitHub <noreply@github.com>2022-10-28 15:54:02 +0200
commit21ec3ebe26bff24b5fc6d96f86a441c9c9628247 (patch)
treea1a541cbbdce2294059b501d1c9ab69ffe0bae79
parentrework of the color code with & and standard codes (#5416) (diff)
downloadcuberite-21ec3ebe26bff24b5fc6d96f86a441c9c9628247.tar
cuberite-21ec3ebe26bff24b5fc6d96f86a441c9c9628247.tar.gz
cuberite-21ec3ebe26bff24b5fc6d96f86a441c9c9628247.tar.bz2
cuberite-21ec3ebe26bff24b5fc6d96f86a441c9c9628247.tar.lz
cuberite-21ec3ebe26bff24b5fc6d96f86a441c9c9628247.tar.xz
cuberite-21ec3ebe26bff24b5fc6d96f86a441c9c9628247.tar.zst
cuberite-21ec3ebe26bff24b5fc6d96f86a441c9c9628247.zip
Diffstat (limited to '')
-rw-r--r--CONTRIBUTORS1
-rw-r--r--src/ClientHandle.cpp13
-rw-r--r--src/ClientHandle.h1
-rw-r--r--src/Protocol/Protocol_1_10.cpp1
-rw-r--r--src/Protocol/Protocol_1_8.cpp2
-rw-r--r--src/Server.cpp1
-rw-r--r--src/Server.h4
7 files changed, 23 insertions, 0 deletions
diff --git a/CONTRIBUTORS b/CONTRIBUTORS
index 314182d9e..3c6d838e2 100644
--- a/CONTRIBUTORS
+++ b/CONTRIBUTORS
@@ -65,6 +65,7 @@ NiLSPACE (formerly STR_Warrior)
npresley0506
p-mcgowan
Persson-dev
+plan1231
pokechu22
ProjectBM
pwnOrbitals
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;