mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-01 08:50:06 +00:00
Clarified ingest target errors
- Rejected target pack names outside letters, digits, underscores and hyphens before ingest starts - Reported an existing target pack with a translated replace=true hint instead of the raw path
This commit is contained in:
1 parent
7fc8d20516
commit
769e077078
21 files changed
+31
No files matched your search
+4
@@ -29,6 +29,7 @@ import java.util.regex.Pattern;
|
||||
record ModIngestArguments(String sourcePack, String targetPack, String dimension, Set<String> namespaces, boolean replace) {
|
||||
static final List<String> OPTION_SUGGESTIONS = List.of("dimension=", "namespaces=", "replace=true");
|
||||
private static final Pattern PACK = Pattern.compile("[A-Za-z0-9_.-]+");
|
||||
private static final Pattern TARGET_PACK = Pattern.compile("[A-Za-z0-9_-]+");
|
||||
private static final Pattern DIMENSION = Pattern.compile("[A-Za-z0-9_/.-]+");
|
||||
private static final Pattern NAMESPACE = Pattern.compile("[a-z0-9_.-]+");
|
||||
private static final String DIMENSION_KEY = "dimension";
|
||||
@@ -76,6 +77,9 @@ record ModIngestArguments(String sourcePack, String targetPack, String dimension
|
||||
}
|
||||
requirePack(source);
|
||||
requirePack(target);
|
||||
if (!TARGET_PACK.matcher(target).matches()) {
|
||||
throw new IllegalArgumentException("invalid target pack name '" + target + "'");
|
||||
}
|
||||
if (source.equals(target)) {
|
||||
throw new IllegalArgumentException("source and target must be different packs");
|
||||
}
|
||||
|
||||
+4
@@ -43,6 +43,7 @@ import com.mojang.brigadier.suggestion.SuggestionsBuilder;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.FileAlreadyExistsException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -211,6 +212,9 @@ final class ModdedCatalogCommands {
|
||||
try {
|
||||
ModIngestReport report = ModIngester.ingest(request);
|
||||
source.execute(() -> reportIngest(source, report));
|
||||
} catch (FileAlreadyExistsException exists) {
|
||||
source.execute(() -> IrisModdedCommands.fail(source, IrisLanguage.plain(ModdedCatalogMessages.INGEST_TARGET_EXISTS,
|
||||
MessageArgument.untrusted("target", request.targetPack().getFileName().toString()))));
|
||||
} catch (IOException | RuntimeException failure) {
|
||||
ModdedIrisLog.error("Iris mod ingest into " + request.targetPack() + " failed", failure);
|
||||
String reason = reason(failure);
|
||||
|
||||
+5
@@ -91,6 +91,10 @@ public final class ModdedCatalogMessages {
|
||||
"iris.modded.catalog.ingest_failed",
|
||||
"Mod ingest failed: {reason}"
|
||||
);
|
||||
public static final TextKey INGEST_TARGET_EXISTS = TextKey.of(
|
||||
"iris.modded.catalog.ingest_target_exists",
|
||||
"Target pack '{target}' already exists. Add replace=true to overwrite it."
|
||||
);
|
||||
public static final TextKey INGEST_LINE = TextKey.of(
|
||||
"iris.modded.catalog.ingest_line",
|
||||
" {summary}"
|
||||
@@ -129,6 +133,7 @@ public final class ModdedCatalogMessages {
|
||||
INGEST_PACK_MISSING,
|
||||
INGEST_STARTED,
|
||||
INGEST_FAILED,
|
||||
INGEST_TARGET_EXISTS,
|
||||
INGEST_LINE,
|
||||
INGEST_COMPLETE,
|
||||
HELP_CATALOG,
|
||||
|
||||
Reference in new issue
Block a user