3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-12-25 18:40:05 +01:00

Use FastSchematicReader by default (#2478)

Dieser Commit ist enthalten in:
Hannes Greule 2023-11-18 15:11:17 +01:00 committet von GitHub
Ursprung 46dd71e807
Commit 1a7f555add
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23
2 geänderte Dateien mit 12 neuen und 5 gelöschten Zeilen

Datei anzeigen

@ -313,9 +313,9 @@ public class SchematicCommands {
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
@ -325,6 +325,11 @@ public class SchematicCommands {
//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:")) {
@ -369,7 +374,7 @@ public class SchematicCommands {
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 {

Datei anzeigen

@ -26,7 +26,6 @@ import com.fastasyncworldedit.core.extent.clipboard.MultiClipboardHolder;
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;
@ -51,6 +50,7 @@ import java.util.Collection;
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;
@ -64,7 +64,9 @@ import static com.google.common.base.Preconditions.checkNotNull;
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) {