Files
2019-02-24 22:29:41 +08:00

105 lines
4.3 KiB
Diff

--- ../src-base/minecraft/net/minecraft/command/FunctionObject.java
+++ ../src-work/minecraft/net/minecraft/command/FunctionObject.java
@@ -5,25 +5,26 @@
import java.util.List;
import javax.annotation.Nullable;
import net.minecraft.advancements.FunctionManager;
+import net.minecraft.tileentity.CommandBlockBaseLogic;
import net.minecraft.util.ResourceLocation;
public class FunctionObject
{
- private final FunctionObject.Entry[] entries;
+ private final Entry[] entries;
- public FunctionObject(FunctionObject.Entry[] entriesIn)
+ public FunctionObject(Entry[] entriesIn)
{
this.entries = entriesIn;
}
- public FunctionObject.Entry[] getEntries()
+ public Entry[] getEntries()
{
return this.entries;
}
public static FunctionObject create(FunctionManager functionManagerIn, List<String> commands)
{
- List<FunctionObject.Entry> list = Lists.<FunctionObject.Entry>newArrayListWithCapacity(commands.size());
+ List<Entry> list = Lists.<Entry>newArrayListWithCapacity(commands.size());
for (String s : commands)
{
@@ -49,16 +50,16 @@
throw new IllegalArgumentException("Unknown or invalid command '" + s1 + "'");
}
- list.add(new FunctionObject.CommandEntry(s));
+ list.add(new CommandEntry(s));
}
}
- return new FunctionObject((FunctionObject.Entry[])list.toArray(new FunctionObject.Entry[list.size()]));
+ return new FunctionObject((Entry[])list.toArray(new Entry[list.size()]));
}
public static class CacheableFunction
{
- public static final FunctionObject.CacheableFunction EMPTY = new FunctionObject.CacheableFunction((ResourceLocation)null);
+ public static final CacheableFunction EMPTY = new CacheableFunction((ResourceLocation)null);
@Nullable
private final ResourceLocation id;
private boolean isValid;
@@ -97,7 +98,7 @@
}
}
- public static class CommandEntry implements FunctionObject.Entry
+ public static class CommandEntry implements Entry
{
private final String command;
@@ -108,7 +109,14 @@
public void execute(FunctionManager functionManagerIn, ICommandSender sender, ArrayDeque<FunctionManager.QueuedCommand> commandQueue, int maxCommandChainLength)
{
- functionManagerIn.getCommandManager().executeCommand(sender, this.command);
+// functionManagerIn.getCommandManager().executeCommand(sender, this.command);
+ org.bukkit.command.CommandSender bukkitSender;
+ if (sender instanceof FunctionManager.CustomFunctionListener) {
+ bukkitSender = ((FunctionManager.CustomFunctionListener) sender).sender;
+ } else {
+ bukkitSender = CommandBlockBaseLogic.unwrapSender(sender);
+ }
+ CommandBlockBaseLogic.executeSafely(sender, bukkitSender, this.command);
}
public String toString()
@@ -122,13 +130,13 @@
void execute(FunctionManager functionManagerIn, ICommandSender sender, ArrayDeque<FunctionManager.QueuedCommand> commandQueue, int maxCommandChainLength);
}
- public static class FunctionEntry implements FunctionObject.Entry
+ public static class FunctionEntry implements Entry
{
- private final FunctionObject.CacheableFunction function;
+ private final CacheableFunction function;
public FunctionEntry(FunctionObject functionIn)
{
- this.function = new FunctionObject.CacheableFunction(functionIn);
+ this.function = new CacheableFunction(functionIn);
}
public void execute(FunctionManager functionManagerIn, ICommandSender sender, ArrayDeque<FunctionManager.QueuedCommand> commandQueue, int maxCommandChainLength)
@@ -137,7 +145,7 @@
if (functionobject != null)
{
- FunctionObject.Entry[] afunctionobject$entry = functionobject.getEntries();
+ Entry[] afunctionobject$entry = functionobject.getEntries();
int i = maxCommandChainLength - commandQueue.size();
int j = Math.min(afunctionobject$entry.length, i);