Remove leading slash from command block commands (#4502)
This commit is contained in:
parent
0e07e231a2
commit
646d3d6a2e
@ -163,6 +163,11 @@ void cCommandBlockEntity::Execute()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_Command.empty())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
class CommandBlockOutCb :
|
class CommandBlockOutCb :
|
||||||
public cCommandOutputCallback
|
public cCommandOutputCallback
|
||||||
{
|
{
|
||||||
@ -175,21 +180,30 @@ void cCommandBlockEntity::Execute()
|
|||||||
{
|
{
|
||||||
// Overwrite field
|
// Overwrite field
|
||||||
m_CmdBlock->SetLastOutput(cClientHandle::FormatChatPrefix(m_CmdBlock->GetWorld()->ShouldUseChatPrefixes(), "SUCCESS", cChatColor::Green, cChatColor::White) + a_Text);
|
m_CmdBlock->SetLastOutput(cClientHandle::FormatChatPrefix(m_CmdBlock->GetWorld()->ShouldUseChatPrefixes(), "SUCCESS", cChatColor::Green, cChatColor::White) + a_Text);
|
||||||
|
m_CmdBlock->GetWorld()->BroadcastBlockEntity(m_CmdBlock->GetPos());
|
||||||
}
|
}
|
||||||
} CmdBlockOutCb(this);
|
} CmdBlockOutCb(this);
|
||||||
|
|
||||||
|
AString RealCommand = m_Command;
|
||||||
|
|
||||||
|
// Remove leading slash if it exists, since console commands don't use them
|
||||||
|
if (RealCommand[0] == '/')
|
||||||
|
{
|
||||||
|
RealCommand = RealCommand.substr(1, RealCommand.length());
|
||||||
|
}
|
||||||
|
|
||||||
// Administrator commands are not executable by command blocks:
|
// Administrator commands are not executable by command blocks:
|
||||||
if (
|
if (
|
||||||
(m_Command != "stop") &&
|
(RealCommand != "stop") &&
|
||||||
(m_Command != "restart") &&
|
(RealCommand != "restart") &&
|
||||||
(m_Command != "kick") &&
|
(RealCommand != "kick") &&
|
||||||
(m_Command != "ban") &&
|
(RealCommand != "ban") &&
|
||||||
(m_Command != "ipban")
|
(RealCommand != "ipban")
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
cServer * Server = cRoot::Get()->GetServer();
|
cServer * Server = cRoot::Get()->GetServer();
|
||||||
LOGD("cCommandBlockEntity: Executing command %s", m_Command.c_str());
|
LOGD("cCommandBlockEntity: Executing command %s", m_Command.c_str());
|
||||||
Server->ExecuteConsoleCommand(m_Command, CmdBlockOutCb);
|
Server->ExecuteConsoleCommand(RealCommand, CmdBlockOutCb);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user