diff options
3 files changed, 61 insertions, 0 deletions
diff --git a/nms-patches/CustomFunction.patch b/nms-patches/CustomFunction.patch new file mode 100644 index 00000000..b0429ae1 --- /dev/null +++ b/nms-patches/CustomFunction.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/server/CustomFunction.java ++++ b/net/minecraft/server/CustomFunction.java +@@ -130,7 +130,7 @@ + } + + public void a(CustomFunctionData customfunctiondata, ICommandListener icommandlistener, ArrayDeque<CustomFunctionData.a> arraydeque, int i) { +- customfunctiondata.a().a(icommandlistener, this.a); ++ CommandBlockListenerAbstract.executeSafely(icommandlistener, new org.bukkit.craftbukkit.command.CraftFunctionCommandSender(icommandlistener), this.a); // CraftBukkit + } + + public String toString() { diff --git a/src/main/java/org/bukkit/craftbukkit/command/CraftFunctionCommandSender.java b/src/main/java/org/bukkit/craftbukkit/command/CraftFunctionCommandSender.java new file mode 100644 index 00000000..6bb69bb4 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/command/CraftFunctionCommandSender.java @@ -0,0 +1,47 @@ +package org.bukkit.craftbukkit.command; + +import net.minecraft.server.IChatBaseComponent; +import net.minecraft.server.ICommandListener; +import org.bukkit.craftbukkit.util.CraftChatMessage; + +public class CraftFunctionCommandSender extends ServerCommandSender { + + private final ICommandListener handle; + + public CraftFunctionCommandSender(ICommandListener handle) { + this.handle = handle; + } + + @Override + public void sendMessage(String message) { + for (IChatBaseComponent component : CraftChatMessage.fromString(message)) { + handle.sendMessage(component); + } + } + + @Override + public void sendMessage(String[] messages) { + for (String message : messages) { + sendMessage(message); + } + } + + @Override + public String getName() { + return handle.getName(); + } + + @Override + public boolean isOp() { + return true; + } + + @Override + public void setOp(boolean value) { + throw new UnsupportedOperationException("Cannot change operator status of server function sender"); + } + + public ICommandListener getHandle() { + return handle; + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/command/VanillaCommandWrapper.java b/src/main/java/org/bukkit/craftbukkit/command/VanillaCommandWrapper.java index 14115fb5..03d29fe8 100644 --- a/src/main/java/org/bukkit/craftbukkit/command/VanillaCommandWrapper.java +++ b/src/main/java/org/bukkit/craftbukkit/command/VanillaCommandWrapper.java @@ -158,6 +158,9 @@ public final class VanillaCommandWrapper extends Command { if (sender instanceof ProxiedCommandSender) { return ((ProxiedNativeCommandSender) sender).getHandle(); } + if (sender instanceof CraftFunctionCommandSender) { + return ((CraftFunctionCommandSender) sender).getHandle(); + } throw new IllegalArgumentException("Cannot make " + sender + " a vanilla command listener"); } |