Fix commands from signs not firing command events
This patch changes sign command logic so that `run_command` click events: - are logged to the console - fire PlayerCommandPreprocessEvent - work with double-slash commands like `//wand` - sends failure messages to the player who clicked the sign
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
package io.papermc.paper.commands;
|
||||
|
||||
import net.minecraft.commands.CommandSource;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class DelegatingCommandSource implements CommandSource {
|
||||
|
||||
private final CommandSource delegate;
|
||||
|
||||
public DelegatingCommandSource(CommandSource delegate) {
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendSystemMessage(Component message) {
|
||||
delegate.sendSystemMessage(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptsSuccess() {
|
||||
return delegate.acceptsSuccess();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptsFailure() {
|
||||
return delegate.acceptsFailure();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldInformAdmins() {
|
||||
return delegate.shouldInformAdmins();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandSender getBukkitSender(CommandSourceStack wrapper) {
|
||||
return delegate.getBukkitSender(wrapper);
|
||||
}
|
||||
}
|
||||
@@ -61,7 +61,7 @@ public class BukkitCommandWrapper implements com.mojang.brigadier.Command<Comman
|
||||
CommandSender sender = context.getSource().getBukkitSender();
|
||||
|
||||
try {
|
||||
return this.server.dispatchCommand(sender, context.getInput()) ? 1 : 0;
|
||||
return this.server.dispatchCommand(sender, context.getRange().get(context.getInput())) ? 1 : 0; // Paper - Fix commands from signs not firing command events; actually use the StringRange from context
|
||||
} catch (CommandException ex) {
|
||||
sender.sendMessage(org.bukkit.ChatColor.RED + "An internal error occurred while attempting to perform this command");
|
||||
this.server.getLogger().log(Level.SEVERE, null, ex);
|
||||
|
||||
Reference in New Issue
Block a user