1
0

Adds playerlist header and footer broadcasting (1.8-1.13)

This commit is contained in:
dImrich 2021-02-04 00:33:17 +01:00 committed by Tiger Wang
parent b1b7424c43
commit 925f960ea2
16 changed files with 417 additions and 310 deletions

View File

@ -1584,6 +1584,21 @@ end
},
Notes = "Sends the specified animation of the specified entity to the client. The AnimationNumber is protocol-specific.",
},
SendPlayerListHeaderFooter =
{
Params =
{
{
Type = "cCompositeChat",
Name = "Header",
},
{
Type = "cCompositeChat",
Name = "Footer",
},
},
Desc = "Sends the header and footer of the player list to the client.",
},
SendHideTitle =
{
Notes = "Hides the title. This makes the title and subtitle disappear, but if you call SendTitleTimes() the same title and subtitle will appear again."
@ -11388,6 +11403,21 @@ a_Player:OpenWindow(Window);
},
Notes = "Broadcasts the specified message to all players, with its message type set to mtWarning. Use for concerning events, such as plugin reload etc.",
},
BroadcastPlayerListsHeaderFooter =
{
Params =
{
{
Type = "cCompositeChat",
Name = "Header",
},
{
Type = "cCompositeChat",
Name = "Footer",
},
},
Desc = "Broadcasts the header and footer of the player list to all players.",
},
DoWithPlayerByUUID =
{
Params =

View File

@ -327,6 +327,21 @@ return
},
Notes = "Spawns the specified particles to all players in the world exept the optional ExeptClient. A list of available particles by thinkofdeath can be found {{https://gist.github.com/thinkofdeath/5110835|Here}}",
},
BroadcastPlayerListHeaderFooter =
{
Params =
{
{
Type = "cCompositeChat",
Name = "Header",
},
{
Type = "cCompositeChat",
Name = "Footer",
},
},
Desc = "Broadcasts the header and footer of the player list to all players in the world.",
},
BroadcastSoundEffect =
{
Params =

View File

@ -48,6 +48,7 @@ public:
virtual void BroadcastParticleEffect (const AString & a_ParticleName, Vector3f a_Src, Vector3f a_Offset, float a_ParticleData, int a_ParticleAmount, const cClientHandle * a_Exclude = nullptr) = 0;
virtual void BroadcastParticleEffect (const AString & a_ParticleName, Vector3f a_Src, Vector3f a_Offset, float a_ParticleData, int a_ParticleAmount, std::array<int, 2> a_Data, const cClientHandle * a_Exclude = nullptr) = 0;
virtual void BroadcastPlayerListAddPlayer (const cPlayer & a_Player, const cClientHandle * a_Exclude = nullptr) = 0;
virtual void BroadcastPlayerListHeaderFooter (const cCompositeChat & a_Header, const cCompositeChat & a_Footer) = 0;
virtual void BroadcastPlayerListRemovePlayer (const cPlayer & a_Player, const cClientHandle * a_Exclude = nullptr) = 0;
virtual void BroadcastPlayerListUpdateGameMode (const cPlayer & a_Player, const cClientHandle * a_Exclude = nullptr) = 0;
virtual void BroadcastPlayerListUpdatePing (const cPlayer & a_Player, const cClientHandle * a_Exclude = nullptr) = 0;

View File

@ -418,6 +418,19 @@ void cWorld::BroadcastPlayerListAddPlayer(const cPlayer & a_Player, const cClien
void cWorld::BroadcastPlayerListHeaderFooter(const cCompositeChat & a_Header, const cCompositeChat & a_Footer)
{
ForClientsInWorld(*this, nullptr, [&](cClientHandle & a_Client)
{
a_Client.SendPlayerListHeaderFooter(a_Header, a_Footer);
}
);
}
void cWorld::BroadcastPlayerListRemovePlayer(const cPlayer & a_Player, const cClientHandle * a_Exclude)
{
ForClientsInWorld(*this, a_Exclude, [&](cClientHandle & a_Client)

View File

@ -2625,6 +2625,15 @@ void cClientHandle::SendPlayerListAddPlayer(const cPlayer & a_Player)
void cClientHandle::SendPlayerListHeaderFooter(const cCompositeChat & a_Header, const cCompositeChat & a_Footer)
{
m_Protocol->SendPlayerListHeaderFooter(a_Header, a_Footer);
}
void cClientHandle::SendPlayerListRemovePlayer(const cPlayer & a_Player)
{
m_Protocol->SendPlayerListRemovePlayer(a_Player);

View File

@ -183,6 +183,7 @@ public: // tolua_export
void SendParticleEffect (const AString & a_ParticleName, const Vector3f a_Src, const Vector3f a_Offset, float a_ParticleData, int a_ParticleAmount, std::array<int, 2> a_Data);
void SendPlayerAbilities (void);
void SendPlayerListAddPlayer (const cPlayer & a_Player);
void SendPlayerListHeaderFooter (const cCompositeChat & a_Header, const cCompositeChat & a_Footer); // tolua_export
void SendPlayerListRemovePlayer (const cPlayer & a_Player);
void SendPlayerListUpdateDisplayName(const cPlayer & a_Player, const AString & a_CustomName);
void SendPlayerListUpdateGameMode (const cPlayer & a_Player);

View File

@ -97,6 +97,7 @@ AString cPacketizer::PacketTypeToStr(cProtocol::ePacketType a_PacketType)
case cProtocol::pktPingResponse: return "pktPingResponse";
case cProtocol::pktPlayerAbilities: return "pktPlayerAbilities";
case cProtocol::pktPlayerList: return "pktPlayerList";
case cProtocol::pktPlayerListHeaderFooter: return "pktPlayerListHeaderFooter";
case cProtocol::pktPlayerMaxSpeed: return "pktPlayerMaxSpeed";
case cProtocol::pktPlayerMoveLook: return "pktPlayerMoveLook";
case cProtocol::pktPluginMessage: return "pktPluginMessage";

View File

@ -102,6 +102,7 @@ public:
pktPingResponse,
pktPlayerAbilities,
pktPlayerList,
pktPlayerListHeaderFooter,
pktPlayerMaxSpeed,
pktPlayerMoveLook,
pktPluginMessage,
@ -397,6 +398,7 @@ public:
virtual void SendParticleEffect (const AString & a_SoundName, float a_SrcX, float a_SrcY, float a_SrcZ, float a_OffsetX, float a_OffsetY, float a_OffsetZ, float a_ParticleData, int a_ParticleAmount) = 0;
virtual void SendParticleEffect (const AString & a_SoundName, Vector3f a_Src, Vector3f a_Offset, float a_ParticleData, int a_ParticleAmount, std::array<int, 2> a_Data) = 0;
virtual void SendPlayerListAddPlayer (const cPlayer & a_Player) = 0;
virtual void SendPlayerListHeaderFooter (const cCompositeChat & a_Header, const cCompositeChat & a_Footer) = 0;
virtual void SendPlayerListRemovePlayer (const cPlayer & a_Player) = 0;
virtual void SendPlayerListUpdateGameMode (const cPlayer & a_Player) = 0;
virtual void SendPlayerListUpdatePing (const cPlayer & a_Player) = 0;

View File

@ -1182,6 +1182,7 @@ UInt32 cProtocol_1_12_1::GetPacketID(ePacketType a_Packet)
case pktHeldItemChange: return 0x3a;
case pktLeashEntity: return 0x3d;
case pktPlayerList: return 0x2e;
case pktPlayerListHeaderFooter: return 0x4a;
case pktPlayerAbilities: return 0x2c;
case pktPlayerMaxSpeed: return 0x4e;
case pktPlayerMoveLook: return 0x2f;

View File

@ -367,6 +367,7 @@ UInt32 cProtocol_1_13::GetPacketID(ePacketType a_PacketType)
case pktParticleEffect: return 0x24;
case pktPlayerAbilities: return 0x2e;
case pktPlayerList: return 0x30;
case pktPlayerListHeaderFooter: return 0x4E;
case pktPlayerMaxSpeed: return 0x52;
case pktPlayerMoveLook: return 0x32;
case pktPluginMessage: return 0x19;

View File

@ -994,6 +994,19 @@ void cProtocol_1_8_0::SendPlayerListAddPlayer(const cPlayer & a_Player)
void cProtocol_1_8_0::SendPlayerListHeaderFooter(const cCompositeChat & a_Header, const cCompositeChat & a_Footer)
{
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, pktPlayerListHeaderFooter);
Pkt.WriteString(a_Header.CreateJsonString(false));
Pkt.WriteString(a_Footer.CreateJsonString(false));
}
void cProtocol_1_8_0::SendPlayerListRemovePlayer(const cPlayer & a_Player)
{
ASSERT(m_State == 3); // In game mode?
@ -2083,6 +2096,7 @@ UInt32 cProtocol_1_8_0::GetPacketID(ePacketType a_PacketType)
case pktPingResponse: return 0x01;
case pktPlayerAbilities: return 0x39;
case pktPlayerList: return 0x38;
case pktPlayerListHeaderFooter: return 0x47;
case pktPlayerMoveLook: return 0x08;
case pktPluginMessage: return 0x3f;
case pktRemoveEntityEffect: return 0x1e;

View File

@ -83,6 +83,7 @@ public:
virtual void SendParticleEffect (const AString & a_ParticleName, float a_SrcX, float a_SrcY, float a_SrcZ, float a_OffsetX, float a_OffsetY, float a_OffsetZ, float a_ParticleData, int a_ParticleAmount) override;
virtual void SendParticleEffect (const AString & a_ParticleName, Vector3f a_Src, Vector3f a_Offset, float a_ParticleData, int a_ParticleAmount, std::array<int, 2> a_Data) override;
virtual void SendPlayerListAddPlayer (const cPlayer & a_Player) override;
virtual void SendPlayerListHeaderFooter (const cCompositeChat & a_Header, const cCompositeChat & a_Footer) override;
virtual void SendPlayerListRemovePlayer (const cPlayer & a_Player) override;
virtual void SendPlayerListUpdateGameMode (const cPlayer & a_Player) override;
virtual void SendPlayerListUpdatePing (const cPlayer & a_Player) override;

View File

@ -523,6 +523,7 @@ UInt32 cProtocol_1_9_0::GetPacketID(cProtocol::ePacketType a_Packet)
case pktPingResponse: return 0x01;
case pktPlayerAbilities: return 0x2b;
case pktPlayerList: return 0x2d;
case pktPlayerListHeaderFooter: return 0x48;
case pktPlayerMaxSpeed: return 0x4b;
case pktPlayerMoveLook: return 0x2e;
case pktPluginMessage: return 0x18;
@ -2313,6 +2314,7 @@ UInt32 cProtocol_1_9_4::GetPacketID(cProtocol::ePacketType a_Packet)
case pktEntityEffect: return 0x4b;
case pktEntityProperties: return 0x4a;
case pktPlayerMaxSpeed: return 0x4a;
case pktPlayerListHeaderFooter: return 0x47;
case pktTeleportEntity: return 0x49;
default: return Super::GetPacketID(a_Packet);

View File

@ -648,6 +648,18 @@ void cRoot::BroadcastPlayerListsRemovePlayer(const cPlayer & a_Player, const cCl
void cRoot::BroadcastPlayerListsHeaderFooter(const cCompositeChat & a_Header, const cCompositeChat & a_Footer)
{
for (auto & Entry : m_WorldsByName)
{
Entry.second.BroadcastPlayerListHeaderFooter(a_Header, a_Footer);
}
}
void cRoot::BroadcastChat(const AString & a_Message, eMessageType a_ChatPrefix)
{
for (auto & Entry : m_WorldsByName)

View File

@ -166,6 +166,9 @@ public:
/** Broadcast playerlist removal through all worlds */
void BroadcastPlayerListsRemovePlayer(const cPlayer & a_Player, const cClientHandle * a_Exclude = nullptr);
/** Broadcast playerlist header and footer through all worlds */
void BroadcastPlayerListsHeaderFooter(const cCompositeChat & a_Header, const cCompositeChat & a_Footer); // tolua_export
// tolua_begin
/** Sends a chat message to all connected clients (in all worlds) */

View File

@ -209,6 +209,7 @@ public:
virtual void BroadcastParticleEffect (const AString & a_ParticleName, Vector3f a_Src, Vector3f a_Offset, float a_ParticleData, int a_ParticleAmount, const cClientHandle * a_Exclude = nullptr) override; // Exported in ManualBindings_World.cpp
virtual void BroadcastParticleEffect (const AString & a_ParticleName, Vector3f a_Src, Vector3f a_Offset, float a_ParticleData, int a_ParticleAmount, std::array<int, 2> a_Data, const cClientHandle * a_Exclude = nullptr) override; // Exported in ManualBindings_World.cpp
virtual void BroadcastPlayerListAddPlayer (const cPlayer & a_Player, const cClientHandle * a_Exclude = nullptr) override;
virtual void BroadcastPlayerListHeaderFooter (const cCompositeChat & a_Header, const cCompositeChat & a_Footer) override; // tolua_export
virtual void BroadcastPlayerListRemovePlayer (const cPlayer & a_Player, const cClientHandle * a_Exclude = nullptr) override;
virtual void BroadcastPlayerListUpdateGameMode (const cPlayer & a_Player, const cClientHandle * a_Exclude = nullptr) override;
virtual void BroadcastPlayerListUpdatePing (const cPlayer & a_Player, const cClientHandle * a_Exclude = nullptr) override;