diff --git a/build.gradle b/build.gradle index 7c3d221..033576b 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,7 @@ import groovy.io.FileType apply plugin: 'java-library' apply plugin: 'maven' -version = '0.1.16' +version = '0.1.17' group = 'com.mojang' task wrapper(type: Wrapper) { diff --git a/src/main/java/com/mojang/brigadier/CommandDispatcher.java b/src/main/java/com/mojang/brigadier/CommandDispatcher.java index 03be79d..54bb9b6 100644 --- a/src/main/java/com/mojang/brigadier/CommandDispatcher.java +++ b/src/main/java/com/mojang/brigadier/CommandDispatcher.java @@ -108,7 +108,7 @@ public class CommandDispatcher { if (next == null) { next = new ArrayList<>(1); } - next.add(child); + next.add(child.copyFor(context.getSource())); } else { final Collection results = modifier.apply(context); if (!results.isEmpty()) { diff --git a/src/main/java/com/mojang/brigadier/context/CommandContext.java b/src/main/java/com/mojang/brigadier/context/CommandContext.java index 1f01b1f..e10906e 100644 --- a/src/main/java/com/mojang/brigadier/context/CommandContext.java +++ b/src/main/java/com/mojang/brigadier/context/CommandContext.java @@ -30,6 +30,9 @@ public class CommandContext { } public CommandContext copyFor(final S source) { + if (this.source == source) { + return this; + } return new CommandContext<>(source, input, arguments, command, nodes, range, child, modifier); }