PaperMC/paper-server/patches/sources/net/minecraft/world/level/BaseCommandBlock.java.patch

41 lines
1.9 KiB
Diff
Raw Normal View History

--- a/net/minecraft/world/level/BaseCommandBlock.java
+++ b/net/minecraft/world/level/BaseCommandBlock.java
2024-12-15 00:42:27 +01:00
@@ -32,6 +_,11 @@
private String command = "";
@Nullable
private Component customName;
+ // CraftBukkit start
+ @Override
+ public abstract org.bukkit.command.CommandSender getBukkitSender(CommandSourceStack wrapper);
+ // CraftBukkit end
2024-12-15 00:42:27 +01:00
+
2024-12-15 00:42:27 +01:00
public int getSuccessCount() {
return this.successCount;
@@ -126,7 +_,7 @@
this.successCount++;
}
});
- server.getCommands().performPrefixedCommand(commandSourceStack, this.command);
2024-12-15 16:11:42 +01:00
+ server.getCommands().dispatchServerCommand(commandSourceStack, this.command); // CraftBukkit
2024-12-15 00:42:27 +01:00
} catch (Throwable var6) {
CrashReport crashReport = CrashReport.forThrowable(var6, "Executing command block");
CrashReportCategory crashReportCategory = crashReport.addCategory("Command to be executed");
@@ -162,6 +_,7 @@
@Override
2024-12-15 00:42:27 +01:00
public void sendSystemMessage(Component component) {
if (this.trackOutput) {
+ org.spigotmc.AsyncCatcher.catchOp("sendSystemMessage to a command block"); // Paper - Don't broadcast messages to command blocks
2024-12-15 00:42:27 +01:00
this.lastOutput = Component.literal("[" + TIME_FORMAT.format(new Date()) + "] ").append(component);
this.onUpdated();
}
@@ -184,7 +_,7 @@
2020-05-16 10:05:30 +02:00
}
public InteractionResult usedBy(Player player) {
- if (!player.canUseGameMasterBlocks()) {
+ if (!player.canUseGameMasterBlocks() && (!player.isCreative() || !player.getBukkitEntity().hasPermission("minecraft.commandblock"))) { // Paper - command block permission
return InteractionResult.PASS;
} else {
if (player.getCommandSenderWorld().isClientSide) {