Update Piston to fix bugs

Closes #1292 via Piston fixes.

(cherry picked from commit dc56b602c0367fbd24f954de2b8be4e864add59f)
Dieser Commit ist enthalten in:
Octavia Togami 2020-04-11 22:38:46 -04:00 committet von MattBDev
Ursprung 3426e0103b
Commit 864d160102
12 geänderte Dateien mit 47 neuen und 42 gelöschten Zeilen

Datei anzeigen

@ -3,10 +3,10 @@ import org.gradle.api.Project
object Versions { object Versions {
const val TEXT = "3.0.3" const val TEXT = "3.0.3"
const val TEXT_EXTRAS = "3.0.3" const val TEXT_EXTRAS = "3.0.3"
const val PISTON = "0.5.2" const val PISTON = "0.5.5"
const val AUTO_VALUE = "1.6.5" const val AUTO_VALUE = "1.7"
const val JUNIT = "5.5.0" const val JUNIT = "5.6.1"
const val MOCKITO = "3.0.0" const val MOCKITO = "3.3.3"
const val LOGBACK = "1.2.3" const val LOGBACK = "1.2.3"
} }

Datei anzeigen

@ -665,7 +665,7 @@ public class BrushCommands {
boolean pasteEntities, boolean pasteEntities,
@Switch(name = 'b', desc = "Paste biomes if available") @Switch(name = 'b', desc = "Paste biomes if available")
boolean pasteBiomes, 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 @ClipboardMask
Mask sourceMask, Mask sourceMask,
InjectedValueAccess context) throws WorldEditException { InjectedValueAccess context) throws WorldEditException {

Datei anzeigen

@ -114,7 +114,7 @@ public class ChunkCommands {
@CommandPermissions("worldedit.delchunks") @CommandPermissions("worldedit.delchunks")
@Logging(REGION) @Logging(REGION)
public void deleteChunks(Actor actor, World world, LocalSession session, 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 { ZonedDateTime beforeTime) throws WorldEditException {
Path worldDir = world.getStoragePath(); Path worldDir = world.getStoragePath();
if (worldDir == null) { if (worldDir == null) {

Datei anzeigen

@ -102,7 +102,6 @@ import static com.sk89q.worldedit.command.util.Logging.LogMode.REGION;
@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class) @CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class)
public class ClipboardCommands { public class ClipboardCommands {
@Command( @Command(
name = "/copy", name = "/copy",
aliases = "/cp", aliases = "/cp",
@ -115,11 +114,11 @@ public class ClipboardCommands {
@Switch(name = 'e', desc = "Also copy entities") @Switch(name = 'e', desc = "Also copy entities")
boolean copyEntities, boolean copyEntities,
@Switch(name = 'b', desc = "Also copy biomes") @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") @Switch(name = 'c', desc = "Set the origin of the clipboard to the center of the copied region")
boolean centerClipboard, boolean centerClipboard,
@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", def = "")
Mask mask) throws WorldEditException { Mask mask) throws WorldEditException {
BlockVector3 min = region.getMinimumPoint(); BlockVector3 min = region.getMinimumPoint();
BlockVector3 max = region.getMaximumPoint(); BlockVector3 max = region.getMaximumPoint();
@ -149,6 +148,7 @@ public class ClipboardCommands {
} }
Operations.completeLegacy(copy); Operations.completeLegacy(copy);
session.setClipboard(new ClipboardHolder(clipboard)); session.setClipboard(new ClipboardHolder(clipboard));
copy.getStatusMessages().forEach(actor::print); copy.getStatusMessages().forEach(actor::print);
} }
@ -226,7 +226,7 @@ public class ClipboardCommands {
boolean copyEntities, boolean copyEntities,
@Switch(name = 'b', desc = "Also copy biomes, source biomes are unaffected") @Switch(name = 'b', desc = "Also copy biomes, source biomes are unaffected")
boolean copyBiomes, 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 { Mask mask) throws WorldEditException {
BlockVector3 min = region.getMinimumPoint(); BlockVector3 min = region.getMinimumPoint();
BlockVector3 max = region.getMaximumPoint(); BlockVector3 max = region.getMaximumPoint();
@ -243,7 +243,6 @@ public class ClipboardCommands {
BlockArrayClipboard clipboard = new BlockArrayClipboard(region, actor.getUniqueId()); BlockArrayClipboard clipboard = new BlockArrayClipboard(region, actor.getUniqueId());
clipboard.setOrigin(session.getPlacementPosition(actor)); clipboard.setOrigin(session.getPlacementPosition(actor));
ForwardExtentCopy copy = new ForwardExtentCopy(editSession, region, clipboard, region.getMinimumPoint()); ForwardExtentCopy copy = new ForwardExtentCopy(editSession, region, clipboard, region.getMinimumPoint());
copy.setSourceFunction(new BlockReplace(editSession, leavePattern)); copy.setSourceFunction(new BlockReplace(editSession, leavePattern));
copy.setCopyingEntities(copyEntities); 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") @CommandPermissions("worldedit.clipboard.paste")
@Logging(PLACEMENT) @Logging(PLACEMENT)
public void paste(Actor actor, World world, LocalSession session, EditSession editSession, public void paste(Actor actor, World world, LocalSession session, EditSession editSession,
@Switch(name = 'a', desc = "Skip air blocks") boolean ignoreAirBlocks, @Switch(name = 'a', desc = "Skip air blocks")
@Switch(name = 'o', desc = "Paste at the original position") boolean atOrigin, boolean ignoreAirBlocks,
@Switch(name = 's', desc = "Select the region after pasting") boolean selectPasted, @Switch(name = 'o', desc = "Paste at the original position")
@Switch(name = 'n', desc = "No paste, select only. (Implies -s)") boolean onlySelect, boolean atOrigin,
@Switch(name = 'e', desc = "Paste entities if available") boolean pasteEntities, @Switch(name = 's', desc = "Select the region after pasting")
@Switch(name = 'b', desc = "Paste biomes if available") boolean pasteBiomes, boolean selectPasted,
@ArgFlag(name = 'm', desc = "Only paste blocks matching this mask", def = "") @ClipboardMask @Switch(name = 'n', desc = "No paste, select only. (Implies -s)")
Mask sourceMask) throws WorldEditException { 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(); ClipboardHolder holder = session.getClipboard();
if (holder.getTransform().isIdentity() && editSession.getSourceMask() == null) { if (holder.getTransform().isIdentity() && editSession.getSourceMask() == null) {
@ -409,23 +417,19 @@ public class ClipboardCommands {
} }
if (selectPasted || onlySelect) { if (selectPasted || onlySelect) {
BlockVector3 clipboardOffset = BlockVector3 clipboardOffset = clipboard.getRegion().getMinimumPoint().subtract(clipboard.getOrigin());
clipboard.getRegion().getMinimumPoint().subtract(clipboard.getOrigin()); Vector3 realTo = to.toVector3().add(holder.getTransform().apply(clipboardOffset.toVector3()));
Vector3 realTo = Vector3 max = realTo.add(holder.getTransform().apply(region.getMaximumPoint().subtract(region.getMinimumPoint()).toVector3()));
to.toVector3().add(holder.getTransform().apply(clipboardOffset.toVector3())); RegionSelector selector = new CuboidRegionSelector(world, realTo.toBlockPoint(), max.toBlockPoint());
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); session.setRegionSelector(world, selector);
selector.learnChanges(); selector.learnChanges();
selector.explainRegionAdjust(actor, session); selector.explainRegionAdjust(actor, session);
} }
if (onlySelect) { if (onlySelect) {
actor.printInfo(TranslatableComponent.of("worldedit.paste.selected")); actor.printInfo(TranslatableComponent.of("worldedit.paste.selected"));
} else { } else {
actor.printInfo(TranslatableComponent actor.printInfo(TranslatableComponent.of("worldedit.paste.pasted", TextComponent.of(to.toString())));
.of("worldedit.paste.pasted", TextComponent.of(to.toString())));
} }
messages.forEach(actor::print); messages.forEach(actor::print);
} }
@ -517,7 +521,6 @@ public class ClipboardCommands {
public void flip(Actor actor, LocalSession session, public void flip(Actor actor, LocalSession session,
@Arg(desc = "The direction to flip, defaults to look direction.", def = Direction.AIM) @Arg(desc = "The direction to flip, defaults to look direction.", def = Direction.AIM)
@Direction BlockVector3 direction) throws WorldEditException { @Direction BlockVector3 direction) throws WorldEditException {
ClipboardHolder holder = session.getClipboard(); ClipboardHolder holder = session.getClipboard();
AffineTransform transform = new AffineTransform(); AffineTransform transform = new AffineTransform();
transform = transform.scale(direction.abs().multiply(-2).add(1, 1, 1).toVector3()); transform = transform.scale(direction.abs().multiply(-2).add(1, 1, 1).toVector3());

Datei anzeigen

@ -490,7 +490,7 @@ public class RegionCommands {
boolean copyEntities, boolean copyEntities,
@Switch(name = 'b', desc = "Also copy biomes") @Switch(name = 'b', desc = "Also copy biomes")
boolean copyBiomes, 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 mask) throws WorldEditException {
checkCommandArgument(count >= 1, "Count must be >= 1"); checkCommandArgument(count >= 1, "Count must be >= 1");
@ -561,7 +561,7 @@ public class RegionCommands {
boolean copyEntities, boolean copyEntities,
@Switch(name = 'b', desc = "Also copy biomes") @Switch(name = 'b', desc = "Also copy biomes")
boolean copyBiomes, 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 mask) throws WorldEditException {
Mask combinedMask; Mask combinedMask;

Datei anzeigen

@ -527,7 +527,7 @@ public class SelectionCommands {
boolean clipboardDistr, boolean clipboardDistr,
@Switch(name = 'd', desc = "Separate blocks by state") @Switch(name = 'd', desc = "Separate blocks by state")
boolean separateStates, 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 { Integer page) throws WorldEditException {
List<Countable<BlockState>> distribution; List<Countable<BlockState>> distribution;

Datei anzeigen

@ -111,7 +111,7 @@ public abstract class AbstractDirectionConverter<D> implements ArgumentConverter
} }
@Override @Override
public List<String> getSuggestions(String input) { public List<String> getSuggestions(String input, InjectedValueAccess context) {
return limitByPrefix(suggestions.stream(), input); return limitByPrefix(suggestions.stream(), input);
} }

Datei anzeigen

@ -70,9 +70,10 @@ public class CommaSeparatedValuesConverter<T> implements ArgumentConverter<T> {
} }
@Override @Override
public List<String> getSuggestions(String input) { public List<String> getSuggestions(String input, InjectedValueAccess context) {
String lastInput = Iterables.getLast(COMMA.split(input), ""); String lastInput = Iterables.getLast(COMMA.split(input), "");
return delegate.getSuggestions(lastInput); assert lastInput != null;
return delegate.getSuggestions(lastInput, context);
} }
@Override @Override

Datei anzeigen

@ -55,7 +55,7 @@ public class EntityRemoverConverter implements ArgumentConverter<EntityRemover>
} }
@Override @Override
public List<String> getSuggestions(String input) { public List<String> getSuggestions(String input, InjectedValueAccess context) {
return limitByPrefix(suggestions.stream(), input); return limitByPrefix(suggestions.stream(), input);
} }

Datei anzeigen

@ -133,7 +133,7 @@ public class FactoryConverter<T> implements ArgumentConverter<T> {
} }
@Override @Override
public List<String> getSuggestions(String input) { public List<String> getSuggestions(String input, InjectedValueAccess context) {
return factoryExtractor.apply(worldEdit).getSuggestions(input); return factoryExtractor.apply(worldEdit).getSuggestions(input);
} }

Datei anzeigen

@ -104,7 +104,8 @@ public final class RegistryConverter<V extends Keyed> implements ArgumentConvert
: SuccessfulConversion.fromSingle(result); : SuccessfulConversion.fromSingle(result);
} }
public List<String> getSuggestions(String input) { @Override
public List<String> getSuggestions(String input, InjectedValueAccess context) {
return SuggestionHelper.getRegistrySuggestions(registry, input).collect(Collectors.toList()); return SuggestionHelper.getRegistrySuggestions(registry, input).collect(Collectors.toList());
} }
} }

Datei anzeigen

@ -61,7 +61,7 @@ public class WorldConverter implements ArgumentConverter<World> {
} }
@Override @Override
public List<String> getSuggestions(String input) { public List<String> getSuggestions(String input, InjectedValueAccess context) {
return getWorlds() return getWorlds()
.map(World::getId) .map(World::getId)
.filter(world -> world.startsWith(input)) .filter(world -> world.startsWith(input))