From 8a3e6a12b9a2dc75bf9f381d26b57293d443d1de Mon Sep 17 00:00:00 2001 From: Kenzie Togami Date: Sun, 5 May 2019 22:06:20 -0700 Subject: [PATCH] Implement suggestions for Bukkit + Sponge --- .../worldedit/bukkit/WorldEditListener.java | 30 ----- .../worldedit/bukkit/WorldEditPlugin.java | 6 +- .../sk89q/worldedit/LocalConfiguration.java | 1 - .../platform/CommandSuggestionEvent.java | 16 ++- .../platform/PlatformCommandManager.java | 63 +++++----- .../internal/command/CommandArgParser.java | 108 ++++++++++-------- .../internal/command/CommandUtil.java | 44 +++++++ .../worldedit/internal/util/Substring.java | 97 ++++++++++++++++ .../util/PropertiesConfiguration.java | 1 - .../worldedit/util/YAMLConfiguration.java | 2 - .../command/CommandArgParserTest.java | 51 +++++++++ worldedit-forge/build.gradle | 2 +- worldedit-libs/build.gradle | 2 +- .../worldedit/sponge/SpongePlatform.java | 3 +- .../config/ConfigurateConfiguration.java | 2 - 15 files changed, 295 insertions(+), 133 deletions(-) create mode 100644 worldedit-core/src/main/java/com/sk89q/worldedit/internal/util/Substring.java create mode 100644 worldedit-core/src/test/java/com/sk89q/worldedit/internal/command/CommandArgParserTest.java diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditListener.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditListener.java index 7eea4312b..15361fc10 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditListener.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditListener.java @@ -80,36 +80,6 @@ public class WorldEditListener implements Listener { WorldEdit.getInstance().getSessionManager().get(plugin.wrapPlayer(event.getPlayer())); } - /** - * Called when a player attempts to use a command - * - * @param event Relevant event details - */ - @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) - public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) { - String[] split = event.getMessage().split(" "); - - if (split.length > 0) { - split[0] = split[0].substring(1); - split = plugin.getWorldEdit().getPlatformManager().getPlatformCommandManager().commandDetection(split); - } - - final String newMessage = "/" + StringUtil.joinString(split, " "); - - if (!newMessage.equals(event.getMessage())) { - event.setMessage(newMessage); - plugin.getServer().getPluginManager().callEvent(event); - - if (!event.isCancelled()) { - if (!event.getMessage().isEmpty()) { - plugin.getServer().dispatchCommand(event.getPlayer(), event.getMessage().substring(1)); - } - - event.setCancelled(true); - } - } - } - @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onPlayerCommand(PlayerCommandSendEvent event) { InjectedValueStore store = MapBackedValueStore.create(); 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 ff0b03a21..11fc7de09 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 @@ -37,6 +37,7 @@ import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Capability; import com.sk89q.worldedit.extension.platform.Platform; import com.sk89q.worldedit.extent.inventory.BlockBag; +import com.sk89q.worldedit.internal.command.CommandUtil; import com.sk89q.worldedit.registry.state.Property; import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BlockCategory; @@ -313,9 +314,10 @@ public class WorldEditPlugin extends JavaPlugin implements TabCompleter { System.arraycopy(args, 0, split, 1, args.length); split[0] = "/" + cmd.getName(); - CommandSuggestionEvent event = new CommandSuggestionEvent(wrapCommandSender(sender), Joiner.on(" ").join(split)); + String arguments = Joiner.on(" ").join(split); + CommandSuggestionEvent event = new CommandSuggestionEvent(wrapCommandSender(sender), arguments); getWorldEdit().getEventBus().post(event); - return event.getSuggestions(); + return CommandUtil.fixSuggestions(arguments, event.getSuggestions()); } /** diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/LocalConfiguration.java b/worldedit-core/src/main/java/com/sk89q/worldedit/LocalConfiguration.java index 51ace98a8..08594fcfb 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/LocalConfiguration.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/LocalConfiguration.java @@ -58,7 +58,6 @@ public abstract class LocalConfiguration { public String wandItem = "minecraft:wooden_axe"; public boolean superPickaxeDrop = true; public boolean superPickaxeManyDrop = true; - public boolean noDoubleSlash = false; public boolean useInventory = false; public boolean useInventoryOverride = false; public boolean useInventoryCreativeOverride = false; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/event/platform/CommandSuggestionEvent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/event/platform/CommandSuggestionEvent.java index 75483745e..709bcc49c 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/event/platform/CommandSuggestionEvent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/event/platform/CommandSuggestionEvent.java @@ -19,14 +19,15 @@ package com.sk89q.worldedit.event.platform; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.event.Event; import com.sk89q.worldedit.extension.platform.Actor; +import com.sk89q.worldedit.internal.util.Substring; import java.util.Collections; import java.util.List; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Posted when suggestions for auto-completion are requested for command input. */ @@ -34,7 +35,7 @@ public class CommandSuggestionEvent extends Event { private final Actor actor; private final String arguments; - private List suggestions = Collections.emptyList(); + private List suggestions = Collections.emptyList(); /** * Create a new instance. @@ -71,9 +72,14 @@ public class CommandSuggestionEvent extends Event { /** * Get the list of suggestions that are to be presented. * + *

+ * Each Substring holds the replacement as the substring, + * and the replacement range as the original substring range. + *

+ * * @return the list of suggestions */ - public List getSuggestions() { + public List getSuggestions() { return suggestions; } @@ -82,7 +88,7 @@ public class CommandSuggestionEvent extends Event { * * @param suggestions the list of suggestions */ - public void setSuggestions(List suggestions) { + public void setSuggestions(List suggestions) { checkNotNull(suggestions); this.suggestions = suggestions; } 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 e1d293303..bdd904226 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 @@ -91,6 +91,7 @@ import com.sk89q.worldedit.internal.command.CommandLoggingHandler; import com.sk89q.worldedit.internal.command.CommandRegistrationHandler; import com.sk89q.worldedit.internal.command.exception.ExceptionConverter; import com.sk89q.worldedit.internal.command.exception.WorldEditExceptionConverter; +import com.sk89q.worldedit.internal.util.Substring; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.session.request.Request; import com.sk89q.worldedit.util.eventbus.Subscribe; @@ -125,15 +126,14 @@ import org.slf4j.LoggerFactory; import java.io.File; import java.io.IOException; -import java.util.Arrays; import java.util.List; -import java.util.Locale; import java.util.Optional; import java.util.function.Consumer; import java.util.logging.FileHandler; import java.util.logging.Level; import java.util.regex.Pattern; import java.util.stream.Collectors; +import java.util.stream.Stream; import static com.google.common.base.Preconditions.checkNotNull; @@ -419,34 +419,8 @@ public final class PlatformCommandManager { dynamicHandler.setHandler(null); } - public String[] commandDetection(String[] split) { - // Quick script shortcut - if (split[0].matches("^[^/].*\\.js$")) { - String[] newSplit = new String[split.length + 1]; - System.arraycopy(split, 0, newSplit, 1, split.length); - newSplit[0] = "cs"; - newSplit[1] = newSplit[1]; - split = newSplit; - } - - String searchCmd = split[0].toLowerCase(Locale.ROOT); - - // Try to detect the command - if (!commandManager.containsCommand(searchCmd)) { - if (worldEdit.getConfiguration().noDoubleSlash && commandManager.containsCommand("/" + searchCmd)) { - split[0] = "/" + split[0]; - } else if (searchCmd.length() >= 2 && searchCmd.charAt(0) == '/' && commandManager.containsCommand(searchCmd.substring(1))) { - split[0] = split[0].substring(1); - } - } - - return split; - } - - private String[] parseArgs(String input) { - return commandDetection(new CommandArgParser(input.substring(1)) - .parseArgs() - .toArray(String[]::new)); + private Stream parseArgs(String input) { + return new CommandArgParser(CommandArgParser.spaceSplit(input.substring(1))).parseArgs(); } @Subscribe @@ -454,7 +428,9 @@ public final class PlatformCommandManager { Request.reset(); Actor actor = platformManager.createProxyActor(event.getActor()); - String[] split = parseArgs(event.getArguments()); + String[] split = parseArgs(event.getArguments()) + .map(Substring::getSubstring) + .toArray(String[]::new); // No command found! if (!commandManager.containsCommand(split[0])) { @@ -581,13 +557,26 @@ public final class PlatformCommandManager { @Subscribe public void handleCommandSuggestion(CommandSuggestionEvent event) { try { - String[] split = parseArgs(event.getArguments()); - MemoizingValueAccess access = initializeInjectedValues(event::getArguments, event.getActor()); - ImmutableSet suggestions = commandManager.getSuggestions(access, Arrays.asList(split)); + String arguments = event.getArguments(); + List split = parseArgs(arguments).collect(Collectors.toList()); + List argStrings = split.stream() + .map(Substring::getSubstring) + .collect(Collectors.toList()); + MemoizingValueAccess access = initializeInjectedValues(() -> arguments, event.getActor()); + ImmutableSet suggestions = commandManager.getSuggestions(access, argStrings); - log.debug("For input: {}", event.getArguments()); - log.debug("I would suggest this: {}", suggestions); - // TODO send back suggestions + event.setSuggestions(suggestions.stream() + .map(suggestion -> { + Substring original = suggestion.getReplacedArgument() == split.size() + ? Substring.from(arguments, arguments.length() - 1) + : split.get(suggestion.getReplacedArgument()); + // increase original points by 1, for removed `/` in `parseArgs` + return Substring.wrap( + suggestion.getSuggestion(), + original.getStart() + 1, + original.getEnd() + 1 + ); + }).collect(Collectors.toList())); } catch (CommandException e) { event.getActor().printError(e.getMessage()); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/command/CommandArgParser.java b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/command/CommandArgParser.java index e3605b6f8..c7ce23311 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/command/CommandArgParser.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/command/CommandArgParser.java @@ -19,86 +19,94 @@ package com.sk89q.worldedit.internal.command; +import com.google.common.base.Splitter; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Iterables; +import com.sk89q.worldedit.internal.util.Substring; + +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; import java.util.stream.Stream; public class CommandArgParser { + public static ImmutableList spaceSplit(String string) { + ImmutableList.Builder result = ImmutableList.builder(); + int index = 0; + for (String part : Splitter.on(' ').split(string)) { + result.add(Substring.from(string, index, index + part.length())); + index += part.length() + 1; + } + return result.build(); + } + private enum State { NORMAL, QUOTE } - private final Stream.Builder args = Stream.builder(); - private final StringBuilder currentArg = new StringBuilder(); - private final String input; + private final Stream.Builder args = Stream.builder(); + private final List input; + private final List currentArg = new ArrayList<>(); private int index = 0; private State state = State.NORMAL; - public CommandArgParser(String input) { + public CommandArgParser(List input) { this.input = input; } - public Stream parseArgs() { - for (; index < input.length(); index++) { - char c = input.charAt(index); + public Stream parseArgs() { + for (; index < input.size(); index++) { + Substring nextPart = input.get(index); switch (state) { case NORMAL: - handleNormal(c); + handleNormal(nextPart); break; case QUOTE: - handleQuote(c); + handleQuote(nextPart); } } - finishArg(true); return args.build(); } - private void handleNormal(char c) { - switch (c) { - case '"': - state = State.QUOTE; - break; - case ' ': - finishArg(true); - break; - case '\\': - if (index + 1 < input.length()) { - index++; - } - appendChar(input.charAt(index)); - break; - default: - appendChar(c); + private void handleNormal(Substring part) { + if (part.getSubstring().startsWith("\"")) { + state = State.QUOTE; + currentArg.add(Substring.wrap( + part.getSubstring().substring(1), + part.getStart(), part.getEnd() + )); + } else { + currentArg.add(part); + finishArg(); } } - private void handleQuote(char c) { - switch (c) { - case '"': - state = State.NORMAL; - finishArg(false); - break; - case '\\': - if (index + 1 < input.length()) { - index++; - } - appendChar(input.charAt(index)); - break; - default: - appendChar(c); + private void handleQuote(Substring part) { + if (part.getSubstring().endsWith("\"")) { + state = State.NORMAL; + currentArg.add(Substring.wrap( + part.getSubstring().substring(0, part.getSubstring().length() - 1), + part.getStart(), part.getEnd() + )); + finishArg(); + } else { + currentArg.add(part); } } - private void finishArg(boolean requireText) { - if (currentArg.length() == 0 && requireText) { - return; - } - args.add(currentArg.toString()); - currentArg.setLength(0); - } - - private void appendChar(char c) { - currentArg.append(c); + private void finishArg() { + // Merge the arguments into a single, space-joined, string + // Keep the original start + end points. + int start = currentArg.get(0).getStart(); + int end = Iterables.getLast(currentArg).getEnd(); + args.add(Substring.wrap(currentArg.stream() + .map(Substring::getSubstring) + .collect(Collectors.joining(" ")), + start, end + )); + currentArg.clear(); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/command/CommandUtil.java b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/command/CommandUtil.java index 861c7926d..395153e7e 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/command/CommandUtil.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/command/CommandUtil.java @@ -19,15 +19,22 @@ package com.sk89q.worldedit.internal.command; +import com.google.common.collect.Iterables; import com.sk89q.worldedit.extension.platform.PlatformCommandManager; +import com.sk89q.worldedit.internal.util.Substring; import org.enginehub.piston.Command; import org.enginehub.piston.part.SubCommandPart; import java.util.Comparator; +import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.function.Function; import java.util.stream.Collectors; +import static com.google.common.base.Preconditions.checkState; +import static java.util.stream.Collectors.toList; + public class CommandUtil { public static Map getSubCommands(Command currentCommand) { @@ -48,6 +55,43 @@ public class CommandUtil { return BY_CLEAN_NAME; } + /** + * Fix {@code suggestions} to replace the last space-separated word in {@code arguments}. + */ + public static List fixSuggestions(String arguments, List suggestions) { + Substring lastArg = Iterables.getLast(CommandArgParser.spaceSplit(arguments)); + return suggestions.stream() + .map(suggestion -> CommandUtil.suggestLast(lastArg, suggestion)) + .filter(Optional::isPresent) + .map(Optional::get) + .collect(toList()); + } + + /** + * Given the last word of a command, mutate the suggestion to replace the last word, if + * possible. + */ + private static Optional suggestLast(Substring last, Substring suggestion) { + if (suggestion.getStart() == last.getEnd()) { + // this suggestion is for the next argument. + if (last.getSubstring().isEmpty()) { + return Optional.of(suggestion.getSubstring()); + } + return Optional.of(last.getSubstring() + " " + suggestion.getSubstring()); + } + StringBuilder builder = new StringBuilder(last.getSubstring()); + int start = suggestion.getStart() - last.getStart(); + int end = suggestion.getEnd() - last.getStart(); + if (start < 0) { + // Quoted suggestion, can't complete it here. + return Optional.empty(); + } + checkState(end <= builder.length(), + "Suggestion ends too late, last=%s, suggestion=", last, suggestion); + builder.replace(start, end, suggestion.getSubstring()); + return Optional.of(builder.toString()); + } + private CommandUtil() { } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/util/Substring.java b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/util/Substring.java new file mode 100644 index 000000000..fa4049cda --- /dev/null +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/util/Substring.java @@ -0,0 +1,97 @@ +/* + * WorldEdit, a Minecraft world manipulation toolkit + * Copyright (C) sk89q + * Copyright (C) WorldEdit team and contributors + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +package com.sk89q.worldedit.internal.util; + +import java.util.Objects; + +/** + * An explicit substring. Provides the range from which it was taken. + */ +public final class Substring { + + /** + * Take a substring from {@code original}, and {@link #wrap(String, int, int)} it into + * a Substring. + */ + public static Substring from(String original, int start) { + return wrap(original.substring(start), start, original.length()); + } + + /** + * Take a substring from {@code original}, and {@link #wrap(String, int, int)} it into + * a Substring. + */ + public static Substring from(String original, int start, int end) { + return wrap(original.substring(start, end), start, end); + } + + /** + * Wrap the given parameters into a Substring instance. + */ + public static Substring wrap(String substring, int start, int end) { + return new Substring(substring, start, end); + } + + private final String substring; + private final int start; + private final int end; + + private Substring(String substring, int start, int end) { + this.substring = substring; + this.start = start; + this.end = end; + } + + public String getSubstring() { + return substring; + } + + public int getStart() { + return start; + } + + public int getEnd() { + return end; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Substring substring1 = (Substring) o; + return start == substring1.start && + end == substring1.end && + substring.equals(substring1.substring); + } + + @Override + public int hashCode() { + return Objects.hash(substring, start, end); + } + + @Override + public String toString() { + return "Substring{" + + "substring='" + substring + "'" + + ",start=" + start + + ",end=" + end + + "}"; + } +} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/PropertiesConfiguration.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/PropertiesConfiguration.java index 12513b97d..766d7d99c 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/PropertiesConfiguration.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/PropertiesConfiguration.java @@ -99,7 +99,6 @@ public class PropertiesConfiguration extends LocalConfiguration { } superPickaxeDrop = getBool("super-pickaxe-drop-items", superPickaxeDrop); superPickaxeManyDrop = getBool("super-pickaxe-many-drop-items", superPickaxeManyDrop); - noDoubleSlash = getBool("no-double-slash", noDoubleSlash); useInventory = getBool("use-inventory", useInventory); useInventoryOverride = getBool("use-inventory-override", useInventoryOverride); useInventoryCreativeOverride = getBool("use-inventory-creative-override", useInventoryCreativeOverride); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/YAMLConfiguration.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/YAMLConfiguration.java index 5a657584d..5347eae97 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/YAMLConfiguration.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/YAMLConfiguration.java @@ -91,8 +91,6 @@ public class YAMLConfiguration extends LocalConfiguration { superPickaxeManyDrop = config.getBoolean( "super-pickaxe.many-drop-items", superPickaxeManyDrop); - noDoubleSlash = config.getBoolean("no-double-slash", noDoubleSlash); - useInventory = config.getBoolean("use-inventory.enable", useInventory); useInventoryOverride = config.getBoolean("use-inventory.allow-override", useInventoryOverride); diff --git a/worldedit-core/src/test/java/com/sk89q/worldedit/internal/command/CommandArgParserTest.java b/worldedit-core/src/test/java/com/sk89q/worldedit/internal/command/CommandArgParserTest.java new file mode 100644 index 000000000..7c75de4a6 --- /dev/null +++ b/worldedit-core/src/test/java/com/sk89q/worldedit/internal/command/CommandArgParserTest.java @@ -0,0 +1,51 @@ +/* + * WorldEdit, a Minecraft world manipulation toolkit + * Copyright (C) sk89q + * Copyright (C) WorldEdit team and contributors + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +package com.sk89q.worldedit.internal.command; + +import com.google.common.collect.ImmutableList; +import com.sk89q.worldedit.internal.util.Substring; +import org.junit.Test; + +import static com.sk89q.worldedit.internal.command.CommandArgParser.spaceSplit; +import static org.junit.Assert.assertEquals; + +public class CommandArgParserTest { + @Test + public void testSpaceSplit() { + assertEquals(ImmutableList.of( + Substring.wrap("", 0, 0) + ), spaceSplit("")); + assertEquals(ImmutableList.of( + Substring.wrap("ab", 0, 2) + ), spaceSplit("ab")); + assertEquals(ImmutableList.of( + Substring.wrap("", 0, 0), + Substring.wrap("", 1, 1) + ), spaceSplit(" ")); + assertEquals(ImmutableList.of( + Substring.wrap("a", 0, 1), + Substring.wrap("", 2, 2) + ), spaceSplit("a ")); + assertEquals(ImmutableList.of( + Substring.wrap("a", 0, 1), + Substring.wrap("b", 2, 3) + ), spaceSplit("a b")); + } +} diff --git a/worldedit-forge/build.gradle b/worldedit-forge/build.gradle index 2b0b08b52..62ee93b26 100644 --- a/worldedit-forge/build.gradle +++ b/worldedit-forge/build.gradle @@ -24,7 +24,7 @@ configurations.all { Configuration it -> dependencies { compile project(':worldedit-core') - compile 'org.apache.logging.log4j:log4j-slf4j-impl:2.8.1' + compile 'org.apache.logging.log4j:log4j-slf4j-impl:2.11.2' minecraft "net.minecraftforge:forge:${minecraftVersion}-${forgeVersion}" diff --git a/worldedit-libs/build.gradle b/worldedit-libs/build.gradle index c6a53795e..f684475e2 100644 --- a/worldedit-libs/build.gradle +++ b/worldedit-libs/build.gradle @@ -90,7 +90,7 @@ configure(subprojects + project("core:ap")) { def textVersion = "3.0.0" project("core") { - def pistonVersion = '0.2.0' + def pistonVersion = '0.2.1' dependencies { shade "net.kyori:text-api:$textVersion" diff --git a/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongePlatform.java b/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongePlatform.java index dcaeca0b3..33849e915 100644 --- a/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongePlatform.java +++ b/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongePlatform.java @@ -29,6 +29,7 @@ import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Capability; import com.sk89q.worldedit.extension.platform.MultiUserPlatform; import com.sk89q.worldedit.extension.platform.Preference; +import com.sk89q.worldedit.internal.command.CommandUtil; import com.sk89q.worldedit.sponge.config.SpongeConfiguration; import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.registry.Registries; @@ -144,7 +145,7 @@ class SpongePlatform extends AbstractPlatform implements MultiUserPlatform { public List getSuggestions(CommandSource source, String arguments, @Nullable Location targetPosition) throws CommandException { CommandSuggestionEvent weEvent = new CommandSuggestionEvent(SpongeWorldEdit.inst().wrapCommandSource(source), command.getName() + " " + arguments); WorldEdit.getInstance().getEventBus().post(weEvent); - return weEvent.getSuggestions(); + return CommandUtil.fixSuggestions(arguments, weEvent.getSuggestions()); } }; ImmutableList.Builder aliases = ImmutableList.builder(); diff --git a/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/config/ConfigurateConfiguration.java b/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/config/ConfigurateConfiguration.java index eb4c64d50..a3bc382f4 100644 --- a/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/config/ConfigurateConfiguration.java +++ b/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/config/ConfigurateConfiguration.java @@ -98,8 +98,6 @@ public class ConfigurateConfiguration extends LocalConfiguration { superPickaxeDrop = node.getNode("super-pickaxe", "drop-items").getBoolean(superPickaxeDrop); superPickaxeManyDrop = node.getNode("super-pickaxe", "many-drop-items").getBoolean(superPickaxeManyDrop); - noDoubleSlash = node.getNode("no-double-slash").getBoolean(noDoubleSlash); - useInventory = node.getNode("use-inventory", "enable").getBoolean(useInventory); useInventoryOverride = node.getNode("use-inventory", "allow-override").getBoolean(useInventoryOverride); useInventoryCreativeOverride = node.getNode("use-inventory", "creative-mode-overrides").getBoolean(useInventoryCreativeOverride);