From a22bcb1c2aba40f6b7251b7533177099f444d552 Mon Sep 17 00:00:00 2001 From: thislooksfun Date: Thu, 19 Mar 2020 17:23:11 -0500 Subject: [PATCH 1/5] Fix tab completion --- .../com/sk89q/worldedit/bukkit/WorldEditPlugin.java | 2 ++ .../extension/platform/PlatformCommandManager.java | 10 ++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java index 3a2c2d7fd..e2ace7f6a 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java @@ -654,6 +654,8 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter int firstSpace = buffer.indexOf(' '); if (firstSpace < 0) return; String label = buffer.substring(0, firstSpace); + // Strip leading slash, if present. + label = label.startsWith("/") ? label.substring(1) : label; final Optional command = WorldEdit.getInstance().getPlatformManager().getPlatformCommandManager().getCommandManager().getCommand(label); if (!command.isPresent()) return; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformCommandManager.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformCommandManager.java index 205a5e966..dbd1e841b 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformCommandManager.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformCommandManager.java @@ -815,7 +815,10 @@ public final class PlatformCommandManager { @Subscribe public void handleCommandSuggestion(CommandSuggestionEvent event) { try { - String arguments = event.getArguments(); + String rawArgs = event.getArguments(); + // Increase the resulting positions by 1 if we remove a leading `/` + final int posOffset = rawArgs.startsWith("/") ? 1 : 0; + String arguments = rawArgs.startsWith("/") ? rawArgs.substring(1) : rawArgs; List split = parseArgs(arguments).collect(Collectors.toList()); List argStrings = split.stream() .map(Substring::getSubstring) @@ -837,11 +840,10 @@ public final class PlatformCommandManager { Substring original = suggestion.getReplacedArgument() == split.size() ? Substring.from(arguments, noSlashLength, noSlashLength) : split.get(suggestion.getReplacedArgument()); - // increase original points by 1, for removed `/` in `parseArgs` return Substring.wrap( suggestion.getSuggestion(), - original.getStart() + 1, - original.getEnd() + 1 + original.getStart() + posOffset, + original.getEnd() + posOffset ); }).collect(Collectors.toList())); } catch (ConditionFailedException e) { From 222f2d261953a5db688c4379bc0af7c5f56783db Mon Sep 17 00:00:00 2001 From: Matt <4009945+MattBDev@users.noreply.github.com> Date: Thu, 19 Mar 2020 18:45:24 -0400 Subject: [PATCH 2/5] Add downloading buildtools to workflow --- .github/workflows/gradle.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 9162a00c1..691d5fb03 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -18,5 +18,8 @@ jobs: uses: actions/setup-java@v1 with: java-version: 1.8 + - name: Download BuildTools + run: wget https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar - name: Test with Gradle run: ./gradlew clean build -x test + From 49584c9435b5f4e709ecd9a7bb73480b9ed30a51 Mon Sep 17 00:00:00 2001 From: Matt <4009945+MattBDev@users.noreply.github.com> Date: Thu, 19 Mar 2020 18:47:48 -0400 Subject: [PATCH 3/5] Add running BuildTools to workflow --- .github/workflows/gradle.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 691d5fb03..c0381b45c 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -20,6 +20,8 @@ jobs: java-version: 1.8 - name: Download BuildTools run: wget https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar + - name: Run BuildTools + run: java -jar BuildTools.jar --rev latest - name: Test with Gradle run: ./gradlew clean build -x test From 64cae57319f1575f956b13995a5d8083eee32d08 Mon Sep 17 00:00:00 2001 From: thislooksfun Date: Thu, 19 Mar 2020 18:14:55 -0500 Subject: [PATCH 4/5] Fix clamping issue --- .../platform/binding/PrimitiveBindings.java | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/binding/PrimitiveBindings.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/binding/PrimitiveBindings.java index 991b27ee2..7c5436818 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/binding/PrimitiveBindings.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/binding/PrimitiveBindings.java @@ -105,13 +105,13 @@ public class PrimitiveBindings extends Bindings { final double radiusX, radiusY, radiusZ; switch (radii.length) { case 1: - radiusX = radiusY = radiusZ = Math.max(1, PrimitiveBindings.parseNumericInput(radii[0])); + radiusX = radiusY = radiusZ = PrimitiveBindings.parseNumericInput(radii[0]); break; case 3: - radiusX = Math.max(1, PrimitiveBindings.parseNumericInput(radii[0])); - radiusY = Math.max(1, PrimitiveBindings.parseNumericInput(radii[1])); - radiusZ = Math.max(1, PrimitiveBindings.parseNumericInput(radii[2])); + radiusX = PrimitiveBindings.parseNumericInput(radii[0]); + radiusY = PrimitiveBindings.parseNumericInput(radii[1]); + radiusZ = PrimitiveBindings.parseNumericInput(radii[2]); break; default: @@ -135,12 +135,12 @@ public class PrimitiveBindings extends Bindings { final double radiusX, radiusZ; switch (radii.length) { case 1: - radiusX = radiusZ = Math.max(1, PrimitiveBindings.parseNumericInput(radii[0])); + radiusX = radiusZ = PrimitiveBindings.parseNumericInput(radii[0]); break; case 2: - radiusX = Math.max(1, PrimitiveBindings.parseNumericInput(radii[0])); - radiusZ = Math.max(1, PrimitiveBindings.parseNumericInput(radii[1])); + radiusX = PrimitiveBindings.parseNumericInput(radii[0]); + radiusZ = PrimitiveBindings.parseNumericInput(radii[1]); break; default: @@ -163,13 +163,13 @@ public class PrimitiveBindings extends Bindings { final double radiusX, radiusY, radiusZ; switch (radii.length) { case 1: - radiusX = radiusY = radiusZ = Math.max(1, PrimitiveBindings.parseNumericInput(radii[0])); + radiusX = radiusY = radiusZ = PrimitiveBindings.parseNumericInput(radii[0]); break; case 3: - radiusX = Math.max(1, PrimitiveBindings.parseNumericInput(radii[0])); - radiusY = Math.max(1, PrimitiveBindings.parseNumericInput(radii[1])); - radiusZ = Math.max(1, PrimitiveBindings.parseNumericInput(radii[2])); + radiusX = PrimitiveBindings.parseNumericInput(radii[0]); + radiusY = PrimitiveBindings.parseNumericInput(radii[1]); + radiusZ = PrimitiveBindings.parseNumericInput(radii[2]); break; default: @@ -192,12 +192,12 @@ public class PrimitiveBindings extends Bindings { final double radiusX, radiusZ; switch (radii.length) { case 1: - radiusX = radiusZ = Math.max(1, parseNumericInput(radii[0])); + radiusX = radiusZ = parseNumericInput(radii[0]); break; case 2: - radiusX = Math.max(1, parseNumericInput(radii[0])); - radiusZ = Math.max(1, parseNumericInput(radii[1])); + radiusX = parseNumericInput(radii[0]); + radiusZ = parseNumericInput(radii[1]); break; default: From 1c9c67026952156701c20e56832478563fc6518b Mon Sep 17 00:00:00 2001 From: Matt <4009945+MattBDev@users.noreply.github.com> Date: Thu, 19 Mar 2020 20:12:21 -0400 Subject: [PATCH 5/5] Update workflow --- .github/workflows/gradle.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index c0381b45c..96e52b293 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -3,19 +3,20 @@ name: Java CI on: push: branches: - - 1.15 + - '1.15' pull_request: branches: - - 1.15 + - '1.15' jobs: test: runs-on: ubuntu-18.04 steps: - - uses: actions/checkout@v1 - - name: Set up JDK 1.8 - uses: actions/setup-java@v1 + - name: Checkout + uses: actions/checkout@v2.0.0 + - name: Setup Java JDK + uses: actions/setup-java@v1.3.0 with: java-version: 1.8 - name: Download BuildTools