Skip to content

Commit

Permalink
Use FastSchematicReader by default
Browse files Browse the repository at this point in the history
  • Loading branch information
SirYwell committed Nov 1, 2023
1 parent 1f8976b commit c7c6571
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -313,9 +313,9 @@ public void load(
Actor actor, LocalSession session,
@Arg(desc = "File name.")
String filename,
@Arg(desc = "Format name.", def = "fast")
String formatName,
//FAWE start - random rotation
@Arg(desc = "Format name.", def = "")
String formatName,
@Switch(name = 'r', desc = "Apply random rotation to the clipboard")
boolean randomRotate
//FAWE end
Expand All @@ -325,6 +325,11 @@ public void load(
//FAWE start
ClipboardFormat format;
InputStream in = null;
// if format is set explicitly, do not look up by extension!
boolean noExplicitFormat = formatName == null;
if (noExplicitFormat) {
formatName = "fast";
}
try {
URI uri;
if (formatName.startsWith("url:")) {
Expand Down Expand Up @@ -369,7 +374,7 @@ public void load(
actor.print(Caption.of("fawe.error.no-perm", "worldedit.schematic.load.other"));
return;
}
if (filename.matches(".*\\.[\\w].*")) {
if (noExplicitFormat && filename.matches(".*\\.[\\w].*")) {
format = ClipboardFormats
.findByExtension(filename.substring(filename.lastIndexOf('.') + 1));
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import com.fastasyncworldedit.core.extent.clipboard.URIClipboardHolder;
import com.fastasyncworldedit.core.internal.io.FastByteArrayOutputStream;
import com.fastasyncworldedit.core.util.MainUtil;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;
import com.google.common.collect.Multimaps;
import com.google.common.io.ByteSource;
Expand All @@ -51,6 +50,7 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
Expand All @@ -64,7 +64,9 @@
public class ClipboardFormats {

private static final Map<String, ClipboardFormat> aliasMap = new HashMap<>();
private static final Multimap<String, ClipboardFormat> fileExtensionMap = HashMultimap.create();
// FAWE start - keep order of ClipboardFormat entries -> prefer FAST over SPONGE_SCHEMATIC
private static final Multimap<String, ClipboardFormat> fileExtensionMap = Multimaps.newMultimap(new HashMap<>(), LinkedHashSet::new);
// FAWE end
private static final List<ClipboardFormat> registeredFormats = new ArrayList<>();

public static void registerClipboardFormat(ClipboardFormat format) {
Expand Down

0 comments on commit c7c6571

Please sign in to comment.