2021-09-30 23:28:02 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
|
|
|
Date: Thu, 23 Sep 2021 10:40:09 -0700
|
2021-11-25 02:24:51 +01:00
|
|
|
Subject: [PATCH] More CommandBlock API
|
2021-09-30 23:28:02 +02:00
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/io/papermc/paper/commands/PaperCommandBlockHolder.java b/src/main/java/io/papermc/paper/commands/PaperCommandBlockHolder.java
|
|
|
|
new file mode 100644
|
|
|
|
index 0000000000000000000000000000000000000000..0b42306f17bf8850a13a51067c2d19e7583187e5
|
|
|
|
--- /dev/null
|
|
|
|
+++ b/src/main/java/io/papermc/paper/commands/PaperCommandBlockHolder.java
|
|
|
|
@@ -0,0 +1,33 @@
|
|
|
|
+package io.papermc.paper.commands;
|
|
|
|
+
|
|
|
|
+import io.papermc.paper.adventure.PaperAdventure;
|
|
|
|
+import io.papermc.paper.command.CommandBlockHolder;
|
|
|
|
+import net.kyori.adventure.text.Component;
|
|
|
|
+import net.minecraft.world.level.BaseCommandBlock;
|
|
|
|
+import org.jetbrains.annotations.NotNull;
|
|
|
|
+import org.jetbrains.annotations.Nullable;
|
|
|
|
+
|
|
|
|
+public interface PaperCommandBlockHolder extends CommandBlockHolder {
|
|
|
|
+
|
|
|
|
+ BaseCommandBlock getCommandBlockHandle();
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ default @NotNull Component lastOutput() {
|
|
|
|
+ return PaperAdventure.asAdventure(getCommandBlockHandle().getLastOutput());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ default void lastOutput(@Nullable Component lastOutput) {
|
|
|
|
+ getCommandBlockHandle().setLastOutput(PaperAdventure.asVanilla(lastOutput));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ default int getSuccessCount() {
|
|
|
|
+ return getCommandBlockHandle().getSuccessCount();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ default void setSuccessCount(int successCount) {
|
|
|
|
+ getCommandBlockHandle().setSuccessCount(successCount);
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftCommandBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftCommandBlock.java
|
2023-09-29 02:28:26 +02:00
|
|
|
index bdd0647d683565088e5cfcd43fb26f4b776db338..42c39c91d2b8e2bc32592adb8813f8a13936f34a 100644
|
2021-09-30 23:28:02 +02:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftCommandBlock.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftCommandBlock.java
|
2021-10-02 19:21:49 +02:00
|
|
|
@@ -5,7 +5,7 @@ import org.bukkit.World;
|
2021-09-30 23:28:02 +02:00
|
|
|
import org.bukkit.block.CommandBlock;
|
|
|
|
import org.bukkit.craftbukkit.util.CraftChatMessage;
|
|
|
|
|
|
|
|
-public class CraftCommandBlock extends CraftBlockEntityState<CommandBlockEntity> implements CommandBlock {
|
|
|
|
+public class CraftCommandBlock extends CraftBlockEntityState<CommandBlockEntity> implements CommandBlock, io.papermc.paper.commands.PaperCommandBlockHolder {
|
|
|
|
|
2021-10-02 19:21:49 +02:00
|
|
|
public CraftCommandBlock(World world, CommandBlockEntity tileEntity) {
|
|
|
|
super(world, tileEntity);
|
2023-09-29 02:28:26 +02:00
|
|
|
@@ -50,5 +50,10 @@ public class CraftCommandBlock extends CraftBlockEntityState<CommandBlockEntity>
|
2021-09-30 23:28:02 +02:00
|
|
|
public void name(net.kyori.adventure.text.Component name) {
|
2022-06-08 12:20:57 +02:00
|
|
|
getSnapshot().getCommandBlock().setName(name == null ? net.minecraft.network.chat.Component.literal("@") : io.papermc.paper.adventure.PaperAdventure.asVanilla(name));
|
2021-09-30 23:28:02 +02:00
|
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public net.minecraft.world.level.BaseCommandBlock getCommandBlockHandle() {
|
|
|
|
+ return getSnapshot().getCommandBlock();
|
|
|
|
+ }
|
|
|
|
// Paper end
|
|
|
|
}
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartCommand.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartCommand.java
|
2023-08-14 01:32:51 +02:00
|
|
|
index 66fb6aeb49b7e93d2a4d9b5ce7f1a7d68f571cf5..2534abcdce426189ac15e0659ab62840b3d54762 100644
|
2021-09-30 23:28:02 +02:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartCommand.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartCommand.java
|
2023-08-14 01:32:51 +02:00
|
|
|
@@ -13,7 +13,7 @@ import org.bukkit.permissions.PermissionAttachment;
|
2021-09-30 23:28:02 +02:00
|
|
|
import org.bukkit.permissions.PermissionAttachmentInfo;
|
|
|
|
import org.bukkit.plugin.Plugin;
|
|
|
|
|
|
|
|
-public class CraftMinecartCommand extends CraftMinecart implements CommandMinecart {
|
|
|
|
+public class CraftMinecartCommand extends CraftMinecart implements CommandMinecart, io.papermc.paper.commands.PaperCommandBlockHolder {
|
|
|
|
private final PermissibleBase perm = new PermissibleBase(this);
|
|
|
|
|
|
|
|
public CraftMinecartCommand(CraftServer server, MinecartCommandBlock entity) {
|
2023-08-14 01:32:51 +02:00
|
|
|
@@ -64,6 +64,17 @@ public class CraftMinecartCommand extends CraftMinecart implements CommandMineca
|
2021-09-30 23:28:02 +02:00
|
|
|
public net.kyori.adventure.text.@org.jetbrains.annotations.NotNull Component name() {
|
|
|
|
return io.papermc.paper.adventure.PaperAdventure.asAdventure(this.getHandle().getCommandBlock().getName());
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public net.minecraft.world.level.BaseCommandBlock getCommandBlockHandle() {
|
|
|
|
+ return getHandle().getCommandBlock();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void lastOutput(net.kyori.adventure.text.Component lastOutput) {
|
|
|
|
+ io.papermc.paper.commands.PaperCommandBlockHolder.super.lastOutput(lastOutput);
|
|
|
|
+ getCommandBlockHandle().onUpdated();
|
|
|
|
+ }
|
|
|
|
// Paper end
|
|
|
|
|
|
|
|
@Override
|