geforkt von Mirrors/Paper
More CommandBlock API (#5746)
Dieser Commit ist enthalten in:
Ursprung
4ee912fbfd
Commit
150389bf71
@ -1103,6 +1103,49 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
/**
|
||||
* Returns a list of entities within a bounding box centered around a
|
||||
* Location.
|
||||
diff --git a/src/main/java/org/bukkit/block/CommandBlock.java b/src/main/java/org/bukkit/block/CommandBlock.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/block/CommandBlock.java
|
||||
+++ b/src/main/java/org/bukkit/block/CommandBlock.java
|
||||
@@ -0,0 +0,0 @@ public interface CommandBlock extends TileState {
|
||||
* by default is "@".
|
||||
*
|
||||
* @return Name of this CommandBlock.
|
||||
+ * @deprecated in favour of {@link #name()}
|
||||
*/
|
||||
+ @Deprecated // Paper
|
||||
@NotNull
|
||||
public String getName();
|
||||
|
||||
@@ -0,0 +0,0 @@ public interface CommandBlock extends TileState {
|
||||
* same as setting it to "@".
|
||||
*
|
||||
* @param name New name for this CommandBlock.
|
||||
+ * @deprecated in favour of {@link #name(net.kyori.adventure.text.Component)}
|
||||
*/
|
||||
+ @Deprecated // Paper
|
||||
public void setName(@Nullable String name);
|
||||
+
|
||||
+ // Paper start
|
||||
+ /**
|
||||
+ * Gets the name of this CommandBlock. The name is used with commands
|
||||
+ * that this CommandBlock executes. This name will never be null, and
|
||||
+ * by default is a {@link net.kyori.adventure.text.TextComponent} containing {@code @}.
|
||||
+ *
|
||||
+ * @return Name of this CommandBlock.
|
||||
+ */
|
||||
+ public @NotNull net.kyori.adventure.text.Component name();
|
||||
+
|
||||
+ /**
|
||||
+ * Sets the name of this CommandBlock. The name is used with commands
|
||||
+ * that this CommandBlock executes. Setting the name to null is the
|
||||
+ * same as setting it to a {@link net.kyori.adventure.text.TextComponent} containing {@code @}.
|
||||
+ *
|
||||
+ * @param name New name for this CommandBlock.
|
||||
+ */
|
||||
+ public void name(@Nullable net.kyori.adventure.text.Component name);
|
||||
+ // Paper end
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/block/Sign.java b/src/main/java/org/bukkit/block/Sign.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/block/Sign.java
|
||||
|
96
patches/api/More-CommandBlock-API.patch
Normale Datei
96
patches/api/More-CommandBlock-API.patch
Normale Datei
@ -0,0 +1,96 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Fri, 28 May 2021 21:47:39 -0700
|
||||
Subject: [PATCH] More CommandBlock API
|
||||
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/command/CommandBlockHolder.java b/src/main/java/io/papermc/paper/command/CommandBlockHolder.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/command/CommandBlockHolder.java
|
||||
@@ -0,0 +0,0 @@
|
||||
+package io.papermc.paper.command;
|
||||
+
|
||||
+import net.kyori.adventure.text.Component;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+import org.jetbrains.annotations.Nullable;
|
||||
+
|
||||
+public interface CommandBlockHolder {
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the command that this CommandBlock will run when powered.
|
||||
+ * This will never return null. If the CommandBlock does not have a
|
||||
+ * command, an empty String will be returned instead.
|
||||
+ *
|
||||
+ * @return Command that this CommandBlock will run when activated.
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ String getCommand();
|
||||
+
|
||||
+ /**
|
||||
+ * Sets the command that this CommandBlock will run when powered.
|
||||
+ * Setting the command to null is the same as setting it to an empty
|
||||
+ * String.
|
||||
+ *
|
||||
+ * @param command Command that this CommandBlock will run when activated.
|
||||
+ */
|
||||
+ void setCommand(@Nullable String command);
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the last output from this command block.
|
||||
+ *
|
||||
+ * @return the last output
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ Component lastOutput();
|
||||
+
|
||||
+ /**
|
||||
+ * Sets the last output from this command block.
|
||||
+ *
|
||||
+ * @param lastOutput the last output
|
||||
+ */
|
||||
+ void lastOutput(@Nullable Component lastOutput);
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the success count from this command block.
|
||||
+ * @see <a href="https://minecraft.fandom.com/wiki/Command_Block#Success_count">Command_Block#Success_count</a>
|
||||
+ *
|
||||
+ * @return the success count
|
||||
+ */
|
||||
+ int getSuccessCount();
|
||||
+
|
||||
+ /**
|
||||
+ * Sets the success count from this command block.
|
||||
+ * @see <a href="https://minecraft.fandom.com/wiki/Command_Block#Success_count">Command_Block#Success_count</a>
|
||||
+ *
|
||||
+ * @param successCount the success count
|
||||
+ */
|
||||
+ void setSuccessCount(int successCount);
|
||||
+}
|
||||
diff --git a/src/main/java/org/bukkit/block/CommandBlock.java b/src/main/java/org/bukkit/block/CommandBlock.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/block/CommandBlock.java
|
||||
+++ b/src/main/java/org/bukkit/block/CommandBlock.java
|
||||
@@ -0,0 +0,0 @@ import org.jetbrains.annotations.Nullable;
|
||||
/**
|
||||
* Represents a captured state of a command block.
|
||||
*/
|
||||
-public interface CommandBlock extends TileState {
|
||||
+public interface CommandBlock extends TileState, io.papermc.paper.command.CommandBlockHolder { // Paper
|
||||
|
||||
/**
|
||||
* Gets the command that this CommandBlock will run when powered.
|
||||
diff --git a/src/main/java/org/bukkit/entity/minecart/CommandMinecart.java b/src/main/java/org/bukkit/entity/minecart/CommandMinecart.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/entity/minecart/CommandMinecart.java
|
||||
+++ b/src/main/java/org/bukkit/entity/minecart/CommandMinecart.java
|
||||
@@ -0,0 +0,0 @@ import org.bukkit.entity.Minecart;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
-public interface CommandMinecart extends Minecart {
|
||||
+public interface CommandMinecart extends Minecart, io.papermc.paper.command.CommandBlockHolder { // Paper
|
||||
|
||||
/**
|
||||
* Gets the command that this CommandMinecart will run when activated.
|
@ -1926,6 +1926,27 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
@Override
|
||||
public String getCustomName() {
|
||||
BeaconBlockEntity beacon = this.getSnapshot();
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftCommandBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftCommandBlock.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftCommandBlock.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftCommandBlock.java
|
||||
@@ -0,0 +0,0 @@ public class CraftCommandBlock extends CraftBlockEntityState<CommandBlockEntity>
|
||||
public void setName(String name) {
|
||||
getSnapshot().getCommandBlock().setName(CraftChatMessage.fromStringOrNull(name != null ? name : "@"));
|
||||
}
|
||||
+
|
||||
+ // Paper start
|
||||
+ @Override
|
||||
+ public net.kyori.adventure.text.Component name() {
|
||||
+ return io.papermc.paper.adventure.PaperAdventure.asAdventure(getSnapshot().getCommandBlock().getName());
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void name(net.kyori.adventure.text.Component name) {
|
||||
+ getSnapshot().getCommandBlock().setName(name == null ? new net.minecraft.network.chat.TextComponent("@") : io.papermc.paper.adventure.PaperAdventure.asVanilla(name));
|
||||
+ }
|
||||
+ // Paper end
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftContainer.java b/src/main/java/org/bukkit/craftbukkit/block/CraftContainer.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftContainer.java
|
||||
|
100
patches/server/More-CommmandBlock-API.patch
Normale Datei
100
patches/server/More-CommmandBlock-API.patch
Normale Datei
@ -0,0 +1,100 @@
|
||||
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
|
||||
Subject: [PATCH] More CommmandBlock API
|
||||
|
||||
|
||||
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..0000000000000000000000000000000000000000
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/commands/PaperCommandBlockHolder.java
|
||||
@@ -0,0 +0,0 @@
|
||||
+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
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftCommandBlock.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftCommandBlock.java
|
||||
@@ -0,0 +0,0 @@ import org.bukkit.block.Block;
|
||||
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 {
|
||||
|
||||
public CraftCommandBlock(Block block) {
|
||||
super(block, CommandBlockEntity.class);
|
||||
@@ -0,0 +0,0 @@ public class CraftCommandBlock extends CraftBlockEntityState<CommandBlockEntity>
|
||||
public void name(net.kyori.adventure.text.Component name) {
|
||||
getSnapshot().getCommandBlock().setName(name == null ? new net.minecraft.network.chat.TextComponent("@") : io.papermc.paper.adventure.PaperAdventure.asVanilla(name));
|
||||
}
|
||||
+
|
||||
+ @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
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartCommand.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartCommand.java
|
||||
@@ -0,0 +0,0 @@ import org.bukkit.permissions.PermissionAttachment;
|
||||
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) {
|
||||
@@ -0,0 +0,0 @@ public class CraftMinecartCommand extends CraftMinecart implements CommandMineca
|
||||
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
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren