Skip to content

Commit

Permalink
fix: prevent commands from logging if PlayerCommandEvent is cancelled.
Browse files Browse the repository at this point in the history
  • Loading branch information
wu-vincent committed Dec 24, 2024
1 parent 87418c7 commit 0719ae5
Showing 1 changed file with 1 addition and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include "endstone/event/player/player_command_event.h"
#include "endstone/event/server/server_command_event.h"

using endstone::detail::EndstonePlayer;
using endstone::detail::EndstoneServer;

MCRESULT MinecraftCommands::executeCommand(CommandContext &ctx, bool suppress_output) const
Expand All @@ -33,15 +32,14 @@ MCRESULT MinecraftCommands::executeCommand(CommandContext &ctx, bool suppress_ou
auto command_line = ctx.getCommand();

if (auto *player = sender->asPlayer(); player) {
server.getLogger().info("{} issued server command: {}", player->getName(), command_line);

endstone::PlayerCommandEvent event(*player, ctx.getCommand());
server.getPluginManager().callEvent(event);

if (event.isCancelled()) {
return MCRESULT_CommandsDisabled;
}
command_line = event.getCommand();
server.getLogger().info("{} issued server command: {}", player->getName(), command_line);
}

if (auto *console = sender->asConsole(); console) {
Expand Down

0 comments on commit 0719ae5

Please sign in to comment.