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:
Brian Neumann-Fopiano committed 2026-10-14 20:18:50 -04:00
1 parent 7fc8d20516
commit 769e077078
21 files changed
+31

No files matched your search

@@ -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");
}
@@ -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);
@@ -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,
@@ -68,6 +68,7 @@ public class ModIngestArgumentsTest {
public void valuesAreValidated() {
assertEquals("replace must be true or false", reason("overworld modded replace=yes"));
assertEquals("invalid pack name '../evil'", reason("../evil modded"));
assertEquals("invalid target pack name 'modded.v2'", reason("overworld modded.v2"));
assertEquals("invalid dimension key 'a..b'", reason("overworld modded dimension=a..b"));
assertEquals("invalid namespace 'Bad'", reason("overworld modded namespaces=ok,Bad"));
assertEquals("namespaces must not be empty", reason("overworld modded namespaces=,"));
@@ -475,6 +475,7 @@ ingest_invalid = "Ungültige Argumente: {reason}. Verwendung: /iris ingest mods
ingest_pack_missing = "Pack '{pack}' wurde unter {path} nicht gefunden."
ingest_started = "Übernehme Mod-Worldgen aus '{source}' in '{target}' (Dimension {dimension})..."
ingest_failed = "Mod-Übernahme fehlgeschlagen: {reason}"
ingest_target_exists = "Ziel-Pack '{target}' existiert bereits. Füge replace=true hinzu, um es zu überschreiben."
ingest_line = " {summary}"
ingest_complete = "Mod-Übernahme abgeschlossen: {path}"
@@ -475,6 +475,7 @@ ingest_invalid = "Argumentos no válidos: {reason}. Uso: /iris ingest mods <sour
ingest_pack_missing = "No se encontró el pack '{pack}' en {path}."
ingest_started = "Incorporando la generación de mods de '{source}' a '{target}' (dimensión {dimension})..."
ingest_failed = "La incorporación de mods falló: {reason}"
ingest_target_exists = "El pack de destino '{target}' ya existe. Añade replace=true para sobrescribirlo."
ingest_line = " {summary}"
ingest_complete = "Incorporación de mods terminada: {path}"
@@ -480,6 +480,7 @@ ingest_invalid = "Virheelliset argumentit: {reason}. Käyttö: /iris ingest mods
ingest_pack_missing = "Pakettia '{pack}' ei löytynyt kohteesta {path}."
ingest_started = "Tuodaan modien maailmangenerointi paketista '{source}' pakettiin '{target}' (ulottuvuus {dimension})..."
ingest_failed = "Modien tuonti epäonnistui: {reason}"
ingest_target_exists = "Kohdepaketti '{target}' on jo olemassa. Lisää replace=true korvataksesi sen."
ingest_line = " {summary}"
ingest_complete = "Modien tuonti valmis: {path}"
@@ -475,6 +475,7 @@ ingest_invalid = "Arguments invalides : {reason}. Utilisation : /iris ingest mod
ingest_pack_missing = "Le pack '{pack}' est introuvable dans {path}."
ingest_started = "Intégration de la génération des mods de '{source}' vers '{target}' (dimension {dimension})..."
ingest_failed = "L'intégration des mods a échoué : {reason}"
ingest_target_exists = "Le pack cible '{target}' existe déjà. Ajoutez replace=true pour le remplacer."
ingest_line = " {summary}"
ingest_complete = "Intégration des mods terminée : {path}"
@@ -480,6 +480,7 @@ ingest_invalid = "ארגומנטים לא תקינים: {reason}. שימוש: /i
ingest_pack_missing = "החבילה '{pack}' לא נמצאה תחת {path}."
ingest_started = "מייבא את יצירת העולם של המודים מ-'{source}' אל '{target}' (ממד {dimension})..."
ingest_failed = "ייבוא המודים נכשל: {reason}"
ingest_target_exists = "חבילת היעד '{target}' כבר קיימת. הוסף replace=true כדי לדרוס אותה."
ingest_line = " {summary}"
ingest_complete = "ייבוא המודים הסתיים: {path}"
@@ -475,6 +475,7 @@ ingest_invalid = "Argomenti non validi: {reason}. Uso: /iris ingest mods <source
ingest_pack_missing = "Il pack '{pack}' non è stato trovato in {path}."
ingest_started = "Importazione della generazione delle mod da '{source}' a '{target}' (dimensione {dimension})..."
ingest_failed = "Importazione delle mod non riuscita: {reason}"
ingest_target_exists = "Il pack di destinazione '{target}' esiste già. Aggiungi replace=true per sovrascriverlo."
ingest_line = " {summary}"
ingest_complete = "Importazione delle mod completata: {path}"
@@ -478,6 +478,7 @@ ingest_invalid = "引数が無効です: {reason}。使い方: /iris ingest mods
ingest_pack_missing = "パック '{pack}' が {path} に見つかりません。"
ingest_started = "'{source}' から '{target}' へ Mod のワールド生成を取り込んでいます (ディメンション {dimension})..."
ingest_failed = "Mod の取り込みに失敗しました: {reason}"
ingest_target_exists = "出力先パック '{target}' はすでに存在します。上書きするには replace=true を追加してください。"
ingest_line = " {summary}"
ingest_complete = "Mod の取り込みが完了しました: {path}"
@@ -478,6 +478,7 @@ ingest_invalid = "잘못된 인수: {reason}. 사용법: /iris ingest mods <sour
ingest_pack_missing = "{path}에서 팩 '{pack}'을(를) 찾을 수 없습니다."
ingest_started = "'{source}'에서 '{target}'(으)로 모드 월드 생성을 가져오는 중 (차원 {dimension})..."
ingest_failed = "모드 가져오기에 실패했습니다: {reason}"
ingest_target_exists = "대상 팩 '{target}'이(가) 이미 있습니다. 덮어쓰려면 replace=true를 추가하세요."
ingest_line = " {summary}"
ingest_complete = "모드 가져오기 완료: {path}"
@@ -480,6 +480,7 @@ ingest_invalid = "Netinkami argumentai: {reason}. Naudojimas: /iris ingest mods
ingest_pack_missing = "Paketas '{pack}' nerastas {path}."
ingest_started = "Perkeliamas modų pasaulio generavimas iš '{source}' į '{target}' (dimensija {dimension})..."
ingest_failed = "Modų perkėlimas nepavyko: {reason}"
ingest_target_exists = "Paskirties paketas '{target}' jau egzistuoja. Pridėk replace=true, kad jį perrašytum."
ingest_line = " {summary}"
ingest_complete = "Modų perkėlimas baigtas: {path}"
@@ -475,6 +475,7 @@ ingest_invalid = "Ongeldige argumenten: {reason}. Gebruik: /iris ingest mods <so
ingest_pack_missing = "Pack '{pack}' is niet gevonden in {path}."
ingest_started = "Wereldgeneratie van mods wordt overgenomen van '{source}' naar '{target}' (dimensie {dimension})..."
ingest_failed = "Overnemen van mods mislukt: {reason}"
ingest_target_exists = "Doelpack '{target}' bestaat al. Voeg replace=true toe om het te overschrijven."
ingest_line = " {summary}"
ingest_complete = "Overnemen van mods voltooid: {path}"
@@ -480,6 +480,7 @@ ingest_invalid = "Nieprawidłowe argumenty: {reason}. Użycie: /iris ingest mods
ingest_pack_missing = "Nie znaleziono paczki '{pack}' w {path}."
ingest_started = "Przenoszenie generowania świata modów z '{source}' do '{target}' (wymiar {dimension})..."
ingest_failed = "Przenoszenie modów nie powiodło się: {reason}"
ingest_target_exists = "Paczka docelowa '{target}' już istnieje. Dodaj replace=true, aby ją nadpisać."
ingest_line = " {summary}"
ingest_complete = "Przenoszenie modów zakończone: {path}"
@@ -475,6 +475,7 @@ ingest_invalid = "Argumentos inválidos: {reason}. Utilização: /iris ingest mo
ingest_pack_missing = "O pack '{pack}' não foi encontrado em {path}."
ingest_started = "A importar a geração de mods de '{source}' para '{target}' (dimensão {dimension})..."
ingest_failed = "A importação de mods falhou: {reason}"
ingest_target_exists = "O pack de destino '{target}' já existe. Adiciona replace=true para o substituir."
ingest_line = " {summary}"
ingest_complete = "Importação de mods concluída: {path}"
@@ -480,6 +480,7 @@ ingest_invalid = "Неверные аргументы: {reason}. Использ
ingest_pack_missing = "Пак '{pack}' не найден в {path}."
ingest_started = "Перенос генерации мира модов из '{source}' в '{target}' (измерение {dimension})..."
ingest_failed = "Не удалось перенести моды: {reason}"
ingest_target_exists = "Целевой пак '{target}' уже существует. Добавьте replace=true, чтобы перезаписать его."
ingest_line = " {summary}"
ingest_complete = "Перенос модов завершён: {path}"
@@ -480,6 +480,7 @@ ingest_invalid = "Geçersiz argümanlar: {reason}. Kullanım: /iris ingest mods
ingest_pack_missing = "'{pack}' paketi {path} altında bulunamadı."
ingest_started = "Mod dünya oluşturması '{source}' paketinden '{target}' paketine aktarılıyor (boyut {dimension})..."
ingest_failed = "Mod aktarımı başarısız oldu: {reason}"
ingest_target_exists = "Hedef paket '{target}' zaten var. Üzerine yazmak için replace=true ekleyin."
ingest_line = " {summary}"
ingest_complete = "Mod aktarımı tamamlandı: {path}"
@@ -478,6 +478,7 @@ ingest_invalid = "Đối số không hợp lệ: {reason}. Cách dùng: /iris in
ingest_pack_missing = "Không tìm thấy gói '{pack}' trong {path}."
ingest_started = "Đang đưa phần tạo thế giới của mod từ '{source}' vào '{target}' (chiều {dimension})..."
ingest_failed = "Đưa mod vào thất bại: {reason}"
ingest_target_exists = "Gói đích '{target}' đã tồn tại. Thêm replace=true để ghi đè."
ingest_line = " {summary}"
ingest_complete = "Đã đưa mod vào xong: {path}"
@@ -478,6 +478,7 @@ ingest_invalid = "参数无效:{reason}。用法:/iris ingest mods <source>
ingest_pack_missing = "在 {path} 下未找到包 '{pack}'。"
ingest_started = "正在将模组世界生成从 '{source}' 导入 '{target}'(维度 {dimension})..."
ingest_failed = "模组导入失败:{reason}"
ingest_target_exists = "目标包 '{target}' 已存在。添加 replace=true 以覆盖它。"
ingest_line = " {summary}"
ingest_complete = "模组导入完成:{path}"
@@ -478,6 +478,7 @@ ingest_invalid = "參數無效:{reason}。用法:/iris ingest mods <source>
ingest_pack_missing = "在 {path} 下找不到包 '{pack}'。"
ingest_started = "正在將模組世界生成從 '{source}' 匯入 '{target}'(維度 {dimension})..."
ingest_failed = "模組匯入失敗:{reason}"
ingest_target_exists = "目標包 '{target}' 已存在。加入 replace=true 以覆寫它。"
ingest_line = " {summary}"
ingest_complete = "模組匯入完成:{path}"