mirror of
https://github.com/FabricMC/fabric.git
synced 2024-11-22 23:58:02 -05:00
Fix incorrect tag warnings, and add fail option. (#3844)
This commit is contained in:
parent
0dcf6c8b90
commit
d153f344b3
6 changed files with 34 additions and 30 deletions
|
@ -432,6 +432,8 @@ loom {
|
|||
inherit testmodClient
|
||||
name "Auto Test Client"
|
||||
vmArg "-Dfabric.autoTest"
|
||||
vmArg "-Dfabric-tag-conventions-v2.missingTagTranslationWarning=fail"
|
||||
vmArg "-Dfabric-tag-conventions-v1.legacyTagWarning=fail"
|
||||
}
|
||||
|
||||
// Create duplicate tasks for this, as jacoco slows things down a bit
|
||||
|
@ -525,6 +527,8 @@ tasks.register('runProductionAutoTestClient', JavaExec) {
|
|||
jvmArgs(
|
||||
"-Dfabric.addMods=${remapJar.archiveFile.get().asFile.absolutePath}${File.pathSeparator}${remapTestmodJar.archiveFile.get().asFile.absolutePath}",
|
||||
"-Dfabric.autoTest",
|
||||
"-Dfabric-tag-conventions-v2.missingTagTranslationWarning=fail",
|
||||
"-Dfabric-tag-conventions-v1.legacyTagWarning=fail"
|
||||
)
|
||||
jvmArgs(debugArgs)
|
||||
}
|
||||
|
|
|
@ -29,7 +29,6 @@ import net.minecraft.registry.DynamicRegistryManager;
|
|||
import net.minecraft.registry.Registry;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.registry.tag.BlockTags;
|
||||
import net.minecraft.registry.tag.ItemTags;
|
||||
import net.minecraft.registry.tag.TagKey;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
@ -49,7 +48,7 @@ public class ConventionLogWarnings implements ModInitializer {
|
|||
private static final LogWarningMode LOG_LEGACY_WARNING_MODE = setupLogWarningModeProperty();
|
||||
|
||||
private static LogWarningMode setupLogWarningModeProperty() {
|
||||
String property = System.getProperty("fabric-tag-conventions-v1.legacyTagWarning", LogWarningMode.DEV_SHORT.name()).toUpperCase(Locale.ROOT);
|
||||
String property = System.getProperty("fabric-tag-conventions-v1.legacyTagWarning", LogWarningMode.SHORT.name()).toUpperCase(Locale.ROOT);
|
||||
|
||||
try {
|
||||
return LogWarningMode.valueOf(property);
|
||||
|
@ -61,8 +60,13 @@ public class ConventionLogWarnings implements ModInitializer {
|
|||
|
||||
private enum LogWarningMode {
|
||||
SILENCED,
|
||||
DEV_SHORT,
|
||||
DEV_VERBOSE
|
||||
SHORT,
|
||||
VERBOSE,
|
||||
FAIL;
|
||||
|
||||
boolean isVerbose() {
|
||||
return this == VERBOSE || this == FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -211,25 +215,7 @@ public class ConventionLogWarnings implements ModInitializer {
|
|||
createMapEntry(RegistryKeys.ITEM, "stews", net.fabricmc.fabric.api.tag.convention.v2.ConventionalItemTags.SOUPS_FOODS),
|
||||
createMapEntry(RegistryKeys.ITEM, "candy", net.fabricmc.fabric.api.tag.convention.v2.ConventionalItemTags.CANDIES_FOODS),
|
||||
createMapEntry(RegistryKeys.ITEM, "candies", net.fabricmc.fabric.api.tag.convention.v2.ConventionalItemTags.CANDIES_FOODS),
|
||||
createMapEntry(TagKey.of(RegistryKeys.ITEM, Identifier.of("minecraft", "music_discs")), net.fabricmc.fabric.api.tag.convention.v2.ConventionalItemTags.MUSIC_DISCS),
|
||||
|
||||
// V2 tags that are now discouraged
|
||||
createMapEntry(ConventionalItemTags.COAL, ItemTags.COALS),
|
||||
createMapEntry(RegistryKeys.ITEM, "tools/shears", net.fabricmc.fabric.api.tag.convention.v2.ConventionalItemTags.SHEAR_TOOLS),
|
||||
createMapEntry(RegistryKeys.ITEM, "tools/spears", net.fabricmc.fabric.api.tag.convention.v2.ConventionalItemTags.SPEAR_TOOLS),
|
||||
createMapEntry(RegistryKeys.ITEM, "tools/bows", net.fabricmc.fabric.api.tag.convention.v2.ConventionalItemTags.BOW_TOOLS),
|
||||
createMapEntry(RegistryKeys.ITEM, "tools/crossbows", net.fabricmc.fabric.api.tag.convention.v2.ConventionalItemTags.CROSSBOW_TOOLS),
|
||||
createMapEntry(RegistryKeys.ITEM, "tools/shields", net.fabricmc.fabric.api.tag.convention.v2.ConventionalItemTags.SHIELD_TOOLS),
|
||||
createMapEntry(RegistryKeys.ITEM, "tools/fishing_rods", net.fabricmc.fabric.api.tag.convention.v2.ConventionalItemTags.FISHING_ROD_TOOLS),
|
||||
createMapEntry(RegistryKeys.ITEM, "tools/brushes", net.fabricmc.fabric.api.tag.convention.v2.ConventionalItemTags.BRUSH_TOOLS),
|
||||
createMapEntry(RegistryKeys.ITEM, "tools/melee_weapons", net.fabricmc.fabric.api.tag.convention.v2.ConventionalItemTags.MELEE_WEAPON_TOOLS),
|
||||
createMapEntry(RegistryKeys.ITEM, "tools/ranged_weapons", net.fabricmc.fabric.api.tag.convention.v2.ConventionalItemTags.RANGED_WEAPON_TOOLS),
|
||||
createMapEntry(RegistryKeys.ITEM, "tools/mining_tools", net.fabricmc.fabric.api.tag.convention.v2.ConventionalItemTags.MINING_TOOL_TOOLS),
|
||||
createMapEntry(RegistryKeys.ITEM, "raw_blocks", net.fabricmc.fabric.api.tag.convention.v2.ConventionalItemTags.STORAGE_BLOCKS),
|
||||
createMapEntry(RegistryKeys.ITEM, "raw_blocks/copper", net.fabricmc.fabric.api.tag.convention.v2.ConventionalItemTags.STORAGE_BLOCKS_RAW_COPPER),
|
||||
createMapEntry(RegistryKeys.ITEM, "raw_blocks/gold", net.fabricmc.fabric.api.tag.convention.v2.ConventionalItemTags.STORAGE_BLOCKS_RAW_GOLD),
|
||||
createMapEntry(RegistryKeys.ITEM, "raw_blocks/iron", net.fabricmc.fabric.api.tag.convention.v2.ConventionalItemTags.STORAGE_BLOCKS_RAW_IRON),
|
||||
createMapEntry(net.fabricmc.fabric.api.tag.convention.v2.ConventionalBlockTags.SHULKER_BOXES, BlockTags.SHULKER_BOXES)
|
||||
createMapEntry(TagKey.of(RegistryKeys.ITEM, Identifier.of("minecraft", "music_discs")), net.fabricmc.fabric.api.tag.convention.v2.ConventionalItemTags.MUSIC_DISCS)
|
||||
);
|
||||
|
||||
@Override
|
||||
|
@ -273,9 +259,7 @@ public class ConventionLogWarnings implements ModInitializer {
|
|||
""");
|
||||
|
||||
// Print out all legacy tags when desired.
|
||||
boolean isConfigSetToVerbose = LOG_LEGACY_WARNING_MODE == LogWarningMode.DEV_VERBOSE;
|
||||
|
||||
if (isConfigSetToVerbose) {
|
||||
if (LOG_LEGACY_WARNING_MODE.isVerbose()) {
|
||||
stringBuilder.append("\nLegacy tags and their replacement:");
|
||||
|
||||
for (TagKey<?> tagKey : legacyTags) {
|
||||
|
@ -284,6 +268,10 @@ public class ConventionLogWarnings implements ModInitializer {
|
|||
}
|
||||
|
||||
LOGGER.warn(stringBuilder.toString());
|
||||
|
||||
if (LOG_LEGACY_WARNING_MODE == LogWarningMode.FAIL) {
|
||||
throw new RuntimeException("Legacy Tag validation failed");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -265,6 +265,7 @@ public class EnglishTagLangGenerator extends FabricLanguageProvider {
|
|||
translationBuilder.add(ConventionalItemTags.PLAYER_WORKSTATIONS_CRAFTING_TABLES, "Crafting Tables");
|
||||
translationBuilder.add(ConventionalItemTags.PLAYER_WORKSTATIONS_FURNACES, "Furnaces");
|
||||
translationBuilder.add(ConventionalItemTags.STRINGS, "Strings");
|
||||
translationBuilder.add(ConventionalItemTags.LEATHERS, "Leathers");
|
||||
translationBuilder.add(ConventionalItemTags.MUSIC_DISCS, "Music Discs");
|
||||
translationBuilder.add(ConventionalItemTags.RODS, "Rods");
|
||||
translationBuilder.add(ConventionalItemTags.WOODEN_RODS, "Wooden Rods");
|
||||
|
|
|
@ -176,6 +176,7 @@
|
|||
"tag.item.c.ingots.gold": "Gold Ingots",
|
||||
"tag.item.c.ingots.iron": "Iron Ingots",
|
||||
"tag.item.c.ingots.netherite": "Netherite Ingots",
|
||||
"tag.item.c.leathers": "Leathers",
|
||||
"tag.item.c.music_discs": "Music Discs",
|
||||
"tag.item.c.nuggets": "Nuggets",
|
||||
"tag.item.c.ores": "Ores",
|
||||
|
|
|
@ -59,7 +59,12 @@ public class TranslationConventionLogWarnings implements ModInitializer {
|
|||
private enum LogWarningMode {
|
||||
SILENCED,
|
||||
SHORT,
|
||||
VERBOSE
|
||||
VERBOSE,
|
||||
FAIL;
|
||||
|
||||
boolean verbose() {
|
||||
return this == VERBOSE || this == FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
public void onInitialize() {
|
||||
|
@ -99,9 +104,7 @@ public class TranslationConventionLogWarnings implements ModInitializer {
|
|||
""");
|
||||
|
||||
// Print out all untranslated tags when desired.
|
||||
boolean isConfigSetToVerbose = LOG_UNTRANSLATED_WARNING_MODE == LogWarningMode.VERBOSE;
|
||||
|
||||
if (isConfigSetToVerbose) {
|
||||
if (LOG_UNTRANSLATED_WARNING_MODE.verbose()) {
|
||||
stringBuilder.append("\nUntranslated item tags:");
|
||||
|
||||
for (TagKey<Item> tagKey : untranslatedItemTags) {
|
||||
|
@ -110,6 +113,10 @@ public class TranslationConventionLogWarnings implements ModInitializer {
|
|||
}
|
||||
|
||||
LOGGER.warn(stringBuilder.toString());
|
||||
|
||||
if (LOG_UNTRANSLATED_WARNING_MODE == LogWarningMode.FAIL) {
|
||||
throw new RuntimeException("Tag translation validation failed");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"tag.item.fabric-resource-conditions-api-v1-testmod.test_condition": "Test Condition"
|
||||
}
|
Loading…
Reference in a new issue