Browse files

Handle commandblocks through ServerCommandEvent

Command blocks/minecarts fire a ServerCommandEvent since CraftBukkit
1.12.1. This commit redirects commands in command blocks/minecarts that
start with "/runalias" to the event handler that handles commands
without a "/runalias" prefix. Effectively, this commit now fires an
external BukkitMCConsoleCommandEvent before CommandHelper handles
command block/minecart commands. This makes the behaviour of command
blocks with and without "/runalias" consistent.
  • Loading branch information...
Pieter12345 committed Sep 28, 2017
1 parent ff4e31d commit e8e01b88f8f28299b8f3f57482d4bf5abf46cba2
Showing with 5 additions and 8 deletions.
  1. +5 −8 src/main/java/com/laytonsmith/commandhelper/
@@ -562,18 +562,15 @@ public boolean onCommand(CommandSender sender, Command cmd, String commandLabel,
if (sender instanceof Player) {
PlayerCommandPreprocessEvent pcpe = new PlayerCommandPreprocessEvent((Player) sender, command);
} else if (sender instanceof ConsoleCommandSender) {
} else if (sender instanceof ConsoleCommandSender
|| sender instanceof BlockCommandSender || sender instanceof CommandMinecart) {
// Console commands and command blocks/minecarts all fire the same event, so pass them to the
// event handler that would get them if they would not have started with "/runalias".
if (command.startsWith("/")) {
command = command.substring(1);
ServerCommandEvent sce = new ServerCommandEvent((ConsoleCommandSender) sender, command);
ServerCommandEvent sce = new ServerCommandEvent(sender, command);
} else if(sender instanceof BlockCommandSender){
MCCommandSender s = new BukkitMCBlockCommandSender((BlockCommandSender) sender);
Static.getAliasCore().alias(command, s);
} else if(sender instanceof CommandMinecart) {
MCCommandSender s = new BukkitMCCommandMinecart((CommandMinecart) sender);
Static.getAliasCore().alias(command, s);
return true;
} else if(cmdName.equalsIgnoreCase("interpreter-on")){

0 comments on commit e8e01b8

Please sign in to comment.