-
-
Notifications
You must be signed in to change notification settings - Fork 386
fix(tmp): try make clipboard patterns safe for Filter #3622
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
Timongcraft
wants to merge
2
commits into
IntellectualSites:main
Choose a base branch
from
Timongcraft:fix/sync-clip-wrapper
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
151 changes: 151 additions & 0 deletions
151
...e/src/main/java/com/fastasyncworldedit/core/extent/clipboard/ConcurrentReadClipboard.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,151 @@ | ||
| package com.fastasyncworldedit.core.extent.clipboard; | ||
|
|
||
| import com.fastasyncworldedit.core.nbt.FaweCompoundTag; | ||
| import com.sk89q.worldedit.entity.Entity; | ||
| import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard; | ||
| import com.sk89q.worldedit.extent.clipboard.Clipboard; | ||
| import com.sk89q.worldedit.math.BlockVector3; | ||
| import com.sk89q.worldedit.regions.Region; | ||
| import com.sk89q.worldedit.world.biome.BiomeType; | ||
| import com.sk89q.worldedit.world.block.BaseBlock; | ||
| import com.sk89q.worldedit.world.block.BlockState; | ||
| import com.sk89q.worldedit.world.block.BlockStateHolder; | ||
| import org.jetbrains.annotations.ApiStatus; | ||
|
|
||
| import javax.annotation.Nonnull; | ||
| import java.util.Iterator; | ||
| import java.util.List; | ||
|
|
||
| @ApiStatus.Experimental // Temporary wrapper | ||
| public class ConcurrentReadClipboard implements Clipboard { | ||
|
|
||
| private final Clipboard parent; | ||
|
|
||
| public static Clipboard tryWrap(Clipboard clipboard) { | ||
| if (clipboard instanceof ConcurrentReadClipboard | ||
| || clipboard instanceof WorldCopyClipboard | ||
| || clipboard instanceof EmptyClipboard | ||
| || clipboard instanceof DiskOptimizedClipboard // FastSchematicReaderV2/V3 no min offset | ||
| || (clipboard instanceof BlockArrayClipboard blockArrayClipboard | ||
| && blockArrayClipboard.getParent() instanceof DiskOptimizedClipboard)) { | ||
| return clipboard; | ||
| } | ||
| return new ConcurrentReadClipboard(clipboard); | ||
| } | ||
|
|
||
| private ConcurrentReadClipboard(Clipboard parent) { | ||
| this.parent = parent; | ||
| } | ||
|
|
||
| @Override | ||
| public synchronized BlockState getBlock(BlockVector3 position) { | ||
| return parent.getBlock(position); | ||
| } | ||
|
|
||
| @Override | ||
| public synchronized BlockState getBlock(int x, int y, int z) { | ||
| return parent.getBlock(x, y, z); | ||
| } | ||
|
|
||
| @Override | ||
| public synchronized BaseBlock getFullBlock(BlockVector3 position) { | ||
| return parent.getFullBlock(position); | ||
| } | ||
|
|
||
| @Override | ||
| public synchronized BaseBlock getFullBlock(int x, int y, int z) { | ||
| return parent.getFullBlock(x, y, z); | ||
| } | ||
|
|
||
| @Override | ||
| public BiomeType getBiomeType(int x, int y, int z) { | ||
| return parent.getBiomeType(x, y, z); | ||
| } | ||
|
|
||
| @Override | ||
| public BiomeType getBiome(BlockVector3 position) { | ||
| return parent.getBiome(position); | ||
| } | ||
|
|
||
| @Override | ||
| public <B extends BlockStateHolder<B>> boolean setBlock(int x, int y, int z, B block) { | ||
| throw new UnsupportedOperationException("Wrapper not intended for writing"); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean tile(int x, int y, int z, FaweCompoundTag tile) { | ||
| throw new UnsupportedOperationException("Wrapper not intended for writing"); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean setBiome(int x, int y, int z, BiomeType biome) { | ||
| throw new UnsupportedOperationException("Wrapper not intended for writing"); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean setBiome(BlockVector3 position, BiomeType biome) { | ||
| throw new UnsupportedOperationException("Wrapper not intended for writing"); | ||
| } | ||
|
|
||
| @Override | ||
| public BlockVector3 getMinimumPoint() { | ||
| return parent.getMinimumPoint(); | ||
| } | ||
|
|
||
| @Override | ||
| public BlockVector3 getMaximumPoint() { | ||
| return parent.getMaximumPoint(); | ||
| } | ||
|
|
||
| @Override | ||
| public List<? extends Entity> getEntities(Region region) { | ||
| return parent.getEntities(region); | ||
| } | ||
|
|
||
| @Override | ||
| public List<? extends Entity> getEntities() { | ||
| return parent.getEntities(); | ||
| } | ||
|
|
||
| @Override | ||
| public Region getRegion() { | ||
| return parent.getRegion(); | ||
| } | ||
|
|
||
| @Override | ||
| public BlockVector3 getDimensions() { | ||
| return parent.getDimensions(); | ||
| } | ||
|
|
||
| @Override | ||
| public BlockVector3 getOrigin() { | ||
| return parent.getOrigin(); | ||
| } | ||
|
|
||
| @Override | ||
| public void setOrigin(BlockVector3 origin) { | ||
| throw new UnsupportedOperationException("Wrapper not intended for writing"); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean hasBiomes() { | ||
| return parent.hasBiomes(); | ||
| } | ||
|
|
||
| @Override | ||
| public void removeEntity(Entity entity) { | ||
| throw new UnsupportedOperationException("Wrapper not intended for writing"); | ||
| } | ||
|
|
||
| @Override | ||
| @Nonnull | ||
| public Iterator<BlockVector3> iterator() { | ||
| return parent.iterator(); | ||
| } | ||
|
|
||
| @Override | ||
| public void close() { | ||
| parent.close(); | ||
| } | ||
|
|
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know it's still in draft, but perhaps we can add a #concurrentAccessSupported function to clipboard
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I appreciate the feedback!
that would be better I just wasn't sure if I should touch that but will do!