-
-
Notifications
You must be signed in to change notification settings - Fork 338
fix: schematic format detection #3289
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
1049aa3
fix: schematic format detection
PierreSchwang feb23a3
chore: adjust filename limitation for sponge v1 check
PierreSchwang 99f4cd9
fix: adjust paper dev bundle version
PierreSchwang abb302c
feat: make schematic format detection faster
PierreSchwang e3ff4ae
chore/test: add tests for new clipboard format detection algorithm
PierreSchwang a57b519
chore: cleanup
PierreSchwang 75f6ab5
Merge branch 'main' into fix/schematicFormatDetection
PierreSchwang ddd9960
chore: specify charset for rootName
PierreSchwang 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
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
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
99 changes: 99 additions & 0 deletions
99
...edit-core/src/test/java/com/sk89q/worldedit/extent/clipboard/io/ClipboardFormatsTest.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,99 @@ | ||
| package com.sk89q.worldedit.extent.clipboard.io; | ||
|
|
||
| import org.junit.jupiter.api.Assertions; | ||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| import java.io.File; | ||
| import java.io.InputStream; | ||
| import java.io.OutputStream; | ||
| import java.nio.file.Path; | ||
| import java.util.Set; | ||
|
|
||
| class ClipboardFormatsTest { | ||
|
|
||
| @Test | ||
| void findByFile() { | ||
| Assertions.assertSame( | ||
| BuiltInClipboardFormat.SPONGE_V1_SCHEMATIC, | ||
| ClipboardFormats.findByFile(getTestSchematic("sponge1.schem")) | ||
| ); | ||
| Assertions.assertSame( | ||
| BuiltInClipboardFormat.FAST_V2, | ||
| ClipboardFormats.findByFile(getTestSchematic("sponge2.schem")) | ||
| ); | ||
| Assertions.assertSame( | ||
| BuiltInClipboardFormat.FAST_V3, | ||
| ClipboardFormats.findByFile(getTestSchematic("sponge3.schem")) | ||
| ); | ||
| Assertions.assertSame( | ||
| BuiltInClipboardFormat.MCEDIT_SCHEMATIC, | ||
| ClipboardFormats.findByFile(getTestSchematic("mcedit.mce")) | ||
| ); | ||
| Assertions.assertSame( | ||
| BuiltInClipboardFormat.MINECRAFT_STRUCTURE, | ||
| ClipboardFormats.findByFile(getTestSchematic("minecraft_structure.nbt")) | ||
| ); | ||
| Assertions.assertSame( | ||
| BuiltInClipboardFormat.PNG, | ||
| ClipboardFormats.findByFile(getTestSchematic("1x1.png")) | ||
| ); | ||
|
|
||
| Assertions.assertNull( | ||
| ClipboardFormats.findByFile(getTestSchematic("custom_format.xyz")) | ||
| ); | ||
| ClipboardFormats.registerClipboardFormat(new CustomTestingClipboardFormat()); | ||
| Assertions.assertInstanceOf( | ||
| CustomTestingClipboardFormat.class, | ||
| ClipboardFormats.findByFile(getTestSchematic("custom_format.xyz")) | ||
| ); | ||
| } | ||
|
|
||
| private static File getTestSchematic(String name) { | ||
| return Path.of("src", "test", "resources", "fastasyncworldedit", "schematics", name).toFile(); | ||
| } | ||
|
|
||
| private static final class CustomTestingClipboardFormat implements ClipboardFormat { | ||
|
|
||
| @Override | ||
| public String getName() { | ||
| return "Custom Testing Format"; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean isFormat(final File file) { | ||
| return file.getName().endsWith(".xyz"); | ||
| } | ||
|
|
||
| @Override | ||
| public Set<String> getAliases() { | ||
| return Set.of(); | ||
| } | ||
|
|
||
| @Override | ||
| public ClipboardReader getReader(final InputStream inputStream) { | ||
| return null; | ||
| } | ||
|
|
||
| @Override | ||
| public ClipboardWriter getWriter(final OutputStream outputStream) { | ||
| return null; | ||
| } | ||
|
|
||
| @Override | ||
| public String getPrimaryFileExtension() { | ||
| return ""; | ||
| } | ||
|
|
||
| @Override | ||
| public Set<String> getFileExtensions() { | ||
| return Set.of(); | ||
| } | ||
|
|
||
| @Override | ||
| public Set<String> getExplicitFileExtensions() { | ||
| return Set.of(); | ||
| } | ||
|
|
||
| } | ||
|
|
||
| } |
Binary file added
BIN
+95 Bytes
worldedit-core/src/test/resources/fastasyncworldedit/schematics/1x1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions
1
worldedit-core/src/test/resources/fastasyncworldedit/schematics/custom_format.xyz
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 @@ | ||
| Hi! |
Binary file added
BIN
+126 Bytes
worldedit-core/src/test/resources/fastasyncworldedit/schematics/mcedit.mce
Binary file not shown.
Binary file added
BIN
+210 Bytes
worldedit-core/src/test/resources/fastasyncworldedit/schematics/minecraft_structure.nbt
Binary file not shown.
Binary file added
BIN
+156 Bytes
worldedit-core/src/test/resources/fastasyncworldedit/schematics/sponge1.schem
Binary file not shown.
Binary file added
BIN
+337 Bytes
worldedit-core/src/test/resources/fastasyncworldedit/schematics/sponge2.schem
Binary file not shown.
Binary file added
BIN
+340 Bytes
worldedit-core/src/test/resources/fastasyncworldedit/schematics/sponge3.schem
Binary file not shown.
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.
Uh oh!
There was an error while loading. Please reload this page.