Setting command-block's command requires a permission. (#5270)
This commit is contained in:
parent
094cd6174f
commit
179d6da490
@ -940,6 +940,11 @@ void cClientHandle::HandleCommandBlockBlockChange(int a_BlockX, int a_BlockY, in
|
|||||||
Kick("Command block string unexpectedly empty - hacked client?");
|
Kick("Command block string unexpectedly empty - hacked client?");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if ((m_Player == nullptr) || !m_Player->HasPermission("comandblock.set"))
|
||||||
|
{
|
||||||
|
SendChat("You cannot edit command blocks on this server", mtFailure);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
cWorld * World = m_Player->GetWorld();
|
cWorld * World = m_Player->GetWorld();
|
||||||
if (World->AreCommandBlocksEnabled())
|
if (World->AreCommandBlocksEnabled())
|
||||||
|
@ -310,11 +310,11 @@ public: // tolua_export
|
|||||||
/** Called when the protocol detects a chat packet. */
|
/** Called when the protocol detects a chat packet. */
|
||||||
void HandleChat(const AString & a_Message);
|
void HandleChat(const AString & a_Message);
|
||||||
|
|
||||||
/** Called when the protocol receives a MC|AdvCdm plugin message, indicating that the player set a new
|
/** Called when the protocol receives a message, indicating that the player set a new
|
||||||
command in the command block UI, for a block-based commandblock. */
|
command in the command block UI, for a block-based commandblock. */
|
||||||
void HandleCommandBlockBlockChange(int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_NewCommand);
|
void HandleCommandBlockBlockChange(int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_NewCommand);
|
||||||
|
|
||||||
/** Called when the protocol receives a MC|AdvCdm plugin message, indicating that the player set a new
|
/** Called when the protocol receives a message, indicating that the player set a new
|
||||||
command in the command block UI, for an entity-based commandblock (minecart?). */
|
command in the command block UI, for an entity-based commandblock (minecart?). */
|
||||||
void HandleCommandBlockEntityChange(UInt32 a_EntityID, const AString & a_NewCommand);
|
void HandleCommandBlockEntityChange(UInt32 a_EntityID, const AString & a_NewCommand);
|
||||||
|
|
||||||
|
@ -2805,27 +2805,37 @@ void cProtocol_1_8_0::HandlePacketWindowClose(cByteBuffer & a_ByteBuffer)
|
|||||||
|
|
||||||
void cProtocol_1_8_0::HandleVanillaPluginMessage(cByteBuffer & a_ByteBuffer, const AString & a_Channel)
|
void cProtocol_1_8_0::HandleVanillaPluginMessage(cByteBuffer & a_ByteBuffer, const AString & a_Channel)
|
||||||
{
|
{
|
||||||
if (a_Channel == "MC|AdvCdm")
|
if ((a_Channel == "MC|AdvCdm") || (a_Channel == "MC|AdvCmd")) // Spelling was fixed in 15w34
|
||||||
{
|
{
|
||||||
HANDLE_READ(a_ByteBuffer, ReadBEUInt8, UInt8, Mode);
|
// https://wiki.vg/index.php?title=Plugin_channels&oldid=14089#MC.7CAdvCmd
|
||||||
|
HANDLE_READ(a_ByteBuffer, ReadBEUInt8, UInt8, Dest);
|
||||||
|
|
||||||
switch (Mode)
|
switch (Dest)
|
||||||
{
|
{
|
||||||
case 0x00:
|
case 0x00:
|
||||||
{
|
{
|
||||||
|
// Editing a command-block
|
||||||
HANDLE_READ(a_ByteBuffer, ReadBEInt32, Int32, BlockX);
|
HANDLE_READ(a_ByteBuffer, ReadBEInt32, Int32, BlockX);
|
||||||
HANDLE_READ(a_ByteBuffer, ReadBEInt32, Int32, BlockY);
|
HANDLE_READ(a_ByteBuffer, ReadBEInt32, Int32, BlockY);
|
||||||
HANDLE_READ(a_ByteBuffer, ReadBEInt32, Int32, BlockZ);
|
HANDLE_READ(a_ByteBuffer, ReadBEInt32, Int32, BlockZ);
|
||||||
HANDLE_READ(a_ByteBuffer, ReadVarUTF8String, AString, Command);
|
HANDLE_READ(a_ByteBuffer, ReadVarUTF8String, AString, Command);
|
||||||
|
|
||||||
m_Client->HandleCommandBlockBlockChange(BlockX, BlockY, BlockZ, Command);
|
m_Client->HandleCommandBlockBlockChange(BlockX, BlockY, BlockZ, Command);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case 0x01:
|
||||||
|
{
|
||||||
|
// Editing a command-block-minecart
|
||||||
|
HANDLE_READ(a_ByteBuffer, ReadBEUInt32, UInt32, EntityID);
|
||||||
|
HANDLE_READ(a_ByteBuffer, ReadVarUTF8String, AString, Command);
|
||||||
|
m_Client->HandleCommandBlockEntityChange(EntityID, Command);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
m_Client->SendChat(Printf("Failure setting command block command; unhandled mode %u (0x%02x)", Mode, Mode), mtFailure);
|
m_Client->SendChat(Printf("Failure setting command block command; unhandled destination %u (0x%02x)", Dest, Dest), mtFailure);
|
||||||
LOG("Unhandled MC|AdvCdm packet mode.");
|
LOG("Unhandled MC|AdvCmd packet destination.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} // switch (Mode)
|
} // switch (Mode)
|
||||||
|
Loading…
Reference in New Issue
Block a user