From 864d1601028e752c966d36fbbbef10c89a922346 Mon Sep 17 00:00:00 2001 From: Octavia Togami Date: Sat, 11 Apr 2020 22:38:46 -0400 Subject: [PATCH] Update Piston to fix bugs Closes #1292 via Piston fixes. (cherry picked from commit dc56b602c0367fbd24f954de2b8be4e864add59f) --- buildSrc/src/main/kotlin/Versions.kt | 8 +-- .../worldedit/command/BrushCommands.java | 2 +- .../worldedit/command/ChunkCommands.java | 2 +- .../worldedit/command/ClipboardCommands.java | 55 ++++++++++--------- .../worldedit/command/RegionCommands.java | 4 +- .../worldedit/command/SelectionCommands.java | 2 +- .../argument/AbstractDirectionConverter.java | 2 +- .../CommaSeparatedValuesConverter.java | 5 +- .../argument/EntityRemoverConverter.java | 2 +- .../command/argument/FactoryConverter.java | 2 +- .../command/argument/RegistryConverter.java | 3 +- .../command/argument/WorldConverter.java | 2 +- 12 files changed, 47 insertions(+), 42 deletions(-) diff --git a/buildSrc/src/main/kotlin/Versions.kt b/buildSrc/src/main/kotlin/Versions.kt index 9234ea8fe..225ebb2cb 100644 --- a/buildSrc/src/main/kotlin/Versions.kt +++ b/buildSrc/src/main/kotlin/Versions.kt @@ -3,10 +3,10 @@ import org.gradle.api.Project object Versions { const val TEXT = "3.0.3" const val TEXT_EXTRAS = "3.0.3" - const val PISTON = "0.5.2" - const val AUTO_VALUE = "1.6.5" - const val JUNIT = "5.5.0" - const val MOCKITO = "3.0.0" + const val PISTON = "0.5.5" + const val AUTO_VALUE = "1.7" + const val JUNIT = "5.6.1" + const val MOCKITO = "3.3.3" const val LOGBACK = "1.2.3" } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java index 3d190d3f7..01a43febb 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java @@ -665,7 +665,7 @@ public class BrushCommands { boolean pasteEntities, @Switch(name = 'b', desc = "Paste biomes if available") boolean pasteBiomes, - @ArgFlag(name = 'm', desc = "Skip blocks matching this mask in the clipboard", def = "") + @ArgFlag(name = 'm', desc = "Skip blocks matching this mask in the clipboard") @ClipboardMask Mask sourceMask, InjectedValueAccess context) throws WorldEditException { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ChunkCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ChunkCommands.java index a5d750c8c..a2c1e3cd1 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ChunkCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ChunkCommands.java @@ -114,7 +114,7 @@ public class ChunkCommands { @CommandPermissions("worldedit.delchunks") @Logging(REGION) public void deleteChunks(Actor actor, World world, LocalSession session, - @ArgFlag(name = 'o', desc = "Only delete chunks older than the specified time.", def = "") + @ArgFlag(name = 'o', desc = "Only delete chunks older than the specified time.") ZonedDateTime beforeTime) throws WorldEditException { Path worldDir = world.getStoragePath(); if (worldDir == null) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java index 90e8187f9..76baa9082 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java @@ -102,7 +102,6 @@ import static com.sk89q.worldedit.command.util.Logging.LogMode.REGION; @CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class) public class ClipboardCommands { - @Command( name = "/copy", aliases = "/cp", @@ -115,11 +114,11 @@ public class ClipboardCommands { @Switch(name = 'e', desc = "Also copy entities") boolean copyEntities, @Switch(name = 'b', desc = "Also copy biomes") - boolean copyBiomes, + boolean copyBiomes, @Switch(name = 'c', desc = "Set the origin of the clipboard to the center of the copied region") boolean centerClipboard, @ArgFlag(name = 'm', desc = "Set the include mask, non-matching blocks become air", def = "") - Mask mask) throws WorldEditException { + Mask mask) throws WorldEditException { BlockVector3 min = region.getMinimumPoint(); BlockVector3 max = region.getMaximumPoint(); @@ -149,6 +148,7 @@ public class ClipboardCommands { } Operations.completeLegacy(copy); session.setClipboard(new ClipboardHolder(clipboard)); + copy.getStatusMessages().forEach(actor::print); } @@ -226,7 +226,7 @@ public class ClipboardCommands { boolean copyEntities, @Switch(name = 'b', desc = "Also copy biomes, source biomes are unaffected") boolean copyBiomes, - @ArgFlag(name = 'm', desc = "Set the exclude mask, non-matching blocks become air", def = "") + @ArgFlag(name = 'm', desc = "Set the exclude mask, non-matching blocks become air") Mask mask) throws WorldEditException { BlockVector3 min = region.getMinimumPoint(); BlockVector3 max = region.getMaximumPoint(); @@ -243,7 +243,6 @@ public class ClipboardCommands { BlockArrayClipboard clipboard = new BlockArrayClipboard(region, actor.getUniqueId()); clipboard.setOrigin(session.getPlacementPosition(actor)); - ForwardExtentCopy copy = new ForwardExtentCopy(editSession, region, clipboard, region.getMinimumPoint()); copy.setSourceFunction(new BlockReplace(editSession, leavePattern)); copy.setCopyingEntities(copyEntities); @@ -371,20 +370,29 @@ public class ClipboardCommands { } } - @Command(name = "/paste", aliases = {"/p", "/pa"}, desc = "Paste the clipboard's contents" - + @Command( + name = "/paste", + aliases = {"/p", "/pa"}, + desc = "Paste the clipboard's contents" ) @CommandPermissions("worldedit.clipboard.paste") @Logging(PLACEMENT) public void paste(Actor actor, World world, LocalSession session, EditSession editSession, - @Switch(name = 'a', desc = "Skip air blocks") boolean ignoreAirBlocks, - @Switch(name = 'o', desc = "Paste at the original position") boolean atOrigin, - @Switch(name = 's', desc = "Select the region after pasting") boolean selectPasted, - @Switch(name = 'n', desc = "No paste, select only. (Implies -s)") boolean onlySelect, - @Switch(name = 'e', desc = "Paste entities if available") boolean pasteEntities, - @Switch(name = 'b', desc = "Paste biomes if available") boolean pasteBiomes, - @ArgFlag(name = 'm', desc = "Only paste blocks matching this mask", def = "") @ClipboardMask - Mask sourceMask) throws WorldEditException { + @Switch(name = 'a', desc = "Skip air blocks") + boolean ignoreAirBlocks, + @Switch(name = 'o', desc = "Paste at the original position") + boolean atOrigin, + @Switch(name = 's', desc = "Select the region after pasting") + boolean selectPasted, + @Switch(name = 'n', desc = "No paste, select only. (Implies -s)") + boolean onlySelect, + @Switch(name = 'e', desc = "Paste entities if available") + boolean pasteEntities, + @Switch(name = 'b', desc = "Paste biomes if available") + boolean pasteBiomes, + @ArgFlag(name = 'm', desc = "Only paste blocks matching this mask") + @ClipboardMask + Mask sourceMask) throws WorldEditException { ClipboardHolder holder = session.getClipboard(); if (holder.getTransform().isIdentity() && editSession.getSourceMask() == null) { @@ -409,23 +417,19 @@ public class ClipboardCommands { } if (selectPasted || onlySelect) { - BlockVector3 clipboardOffset = - clipboard.getRegion().getMinimumPoint().subtract(clipboard.getOrigin()); - Vector3 realTo = - to.toVector3().add(holder.getTransform().apply(clipboardOffset.toVector3())); - Vector3 max = realTo.add(holder.getTransform() - .apply(region.getMaximumPoint().subtract(region.getMinimumPoint()).toVector3())); - RegionSelector selector = - new CuboidRegionSelector(world, realTo.toBlockPoint(), max.toBlockPoint()); + BlockVector3 clipboardOffset = clipboard.getRegion().getMinimumPoint().subtract(clipboard.getOrigin()); + Vector3 realTo = to.toVector3().add(holder.getTransform().apply(clipboardOffset.toVector3())); + Vector3 max = realTo.add(holder.getTransform().apply(region.getMaximumPoint().subtract(region.getMinimumPoint()).toVector3())); + RegionSelector selector = new CuboidRegionSelector(world, realTo.toBlockPoint(), max.toBlockPoint()); session.setRegionSelector(world, selector); selector.learnChanges(); selector.explainRegionAdjust(actor, session); } + if (onlySelect) { actor.printInfo(TranslatableComponent.of("worldedit.paste.selected")); } else { - actor.printInfo(TranslatableComponent - .of("worldedit.paste.pasted", TextComponent.of(to.toString()))); + actor.printInfo(TranslatableComponent.of("worldedit.paste.pasted", TextComponent.of(to.toString()))); } messages.forEach(actor::print); } @@ -517,7 +521,6 @@ public class ClipboardCommands { public void flip(Actor actor, LocalSession session, @Arg(desc = "The direction to flip, defaults to look direction.", def = Direction.AIM) @Direction BlockVector3 direction) throws WorldEditException { - ClipboardHolder holder = session.getClipboard(); AffineTransform transform = new AffineTransform(); transform = transform.scale(direction.abs().multiply(-2).add(1, 1, 1).toVector3()); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java index 0fb201e17..3939babe2 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java @@ -490,7 +490,7 @@ public class RegionCommands { boolean copyEntities, @Switch(name = 'b', desc = "Also copy biomes") boolean copyBiomes, - @ArgFlag(name = 'm', desc = "Set the include mask, non-matching blocks become air", def = "") + @ArgFlag(name = 'm', desc = "Set the include mask, non-matching blocks become air") Mask mask) throws WorldEditException { checkCommandArgument(count >= 1, "Count must be >= 1"); @@ -561,7 +561,7 @@ public class RegionCommands { boolean copyEntities, @Switch(name = 'b', desc = "Also copy biomes") boolean copyBiomes, - @ArgFlag(name = 'm', desc = "Set the include mask, non-matching blocks become air", def = "") + @ArgFlag(name = 'm', desc = "Set the include mask, non-matching blocks become air") Mask mask) throws WorldEditException { Mask combinedMask; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SelectionCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SelectionCommands.java index a0d0556bb..89cdbf862 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SelectionCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SelectionCommands.java @@ -527,7 +527,7 @@ public class SelectionCommands { boolean clipboardDistr, @Switch(name = 'd', desc = "Separate blocks by state") boolean separateStates, - @ArgFlag(name = 'p', desc = "Gets page from a previous distribution.", def = "") + @ArgFlag(name = 'p', desc = "Gets page from a previous distribution.") Integer page) throws WorldEditException { List> distribution; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/AbstractDirectionConverter.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/AbstractDirectionConverter.java index 06ade3a40..c8342b038 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/AbstractDirectionConverter.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/AbstractDirectionConverter.java @@ -111,7 +111,7 @@ public abstract class AbstractDirectionConverter implements ArgumentConverter } @Override - public List getSuggestions(String input) { + public List getSuggestions(String input, InjectedValueAccess context) { return limitByPrefix(suggestions.stream(), input); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/CommaSeparatedValuesConverter.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/CommaSeparatedValuesConverter.java index e02747c3e..296a3c715 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/CommaSeparatedValuesConverter.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/CommaSeparatedValuesConverter.java @@ -70,9 +70,10 @@ public class CommaSeparatedValuesConverter implements ArgumentConverter { } @Override - public List getSuggestions(String input) { + public List getSuggestions(String input, InjectedValueAccess context) { String lastInput = Iterables.getLast(COMMA.split(input), ""); - return delegate.getSuggestions(lastInput); + assert lastInput != null; + return delegate.getSuggestions(lastInput, context); } @Override diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/EntityRemoverConverter.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/EntityRemoverConverter.java index cdbc63e53..a4586a3c0 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/EntityRemoverConverter.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/EntityRemoverConverter.java @@ -55,7 +55,7 @@ public class EntityRemoverConverter implements ArgumentConverter } @Override - public List getSuggestions(String input) { + public List getSuggestions(String input, InjectedValueAccess context) { return limitByPrefix(suggestions.stream(), input); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/FactoryConverter.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/FactoryConverter.java index 5b880f726..e505b86a8 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/FactoryConverter.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/FactoryConverter.java @@ -133,7 +133,7 @@ public class FactoryConverter implements ArgumentConverter { } @Override - public List getSuggestions(String input) { + public List getSuggestions(String input, InjectedValueAccess context) { return factoryExtractor.apply(worldEdit).getSuggestions(input); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/RegistryConverter.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/RegistryConverter.java index 71b82aef4..085ce0cb9 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/RegistryConverter.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/RegistryConverter.java @@ -104,7 +104,8 @@ public final class RegistryConverter implements ArgumentConvert : SuccessfulConversion.fromSingle(result); } - public List getSuggestions(String input) { + @Override + public List getSuggestions(String input, InjectedValueAccess context) { return SuggestionHelper.getRegistrySuggestions(registry, input).collect(Collectors.toList()); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/WorldConverter.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/WorldConverter.java index 1841355fa..586bb7229 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/WorldConverter.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/WorldConverter.java @@ -61,7 +61,7 @@ public class WorldConverter implements ArgumentConverter { } @Override - public List getSuggestions(String input) { + public List getSuggestions(String input, InjectedValueAccess context) { return getWorlds() .map(World::getId) .filter(world -> world.startsWith(input))