-
Notifications
You must be signed in to change notification settings - Fork 0
26.2 Category Prettification and Naming
| Parameter | Specification |
|---|---|
| Helper Class | net.instantgratification.collapsiblegamerules.util.CategoryPrettifier |
| Metadata Facade | net.instantgratification.collapsiblegamerules.util.DasikMetadataHelper |
| Translation Fallback | !Language.getInstance().has(key) |
| Prefix Stripping | Removes "gamerule.category."
|
| Delimiter Handling | Splits by . (namespace) and regex [_-] (words) |
| Dynamic Metadata Provider | DynamicGameRuleManager.getGeneratedTranslations() |
Third-party mods frequently register custom game rule categories using raw translation keys (such as gamerule.category.better-bats.better_bats or gamerule.category.item_clumps) without including localized strings in lang/en_us.json. In vanilla Minecraft, this causes raw, unreadable translation keys to appear on screen.
Category Prettification dynamically cleans, formats, and transforms unlocalized category keys into polished, human-readable Title Case strings.
The formatting logic in CategoryPrettifier.prettifyCategoryKey(String key) executes the following transformation steps:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ CATEGORY PRETTIFICATION PIPELINE โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โ
โ Input Key: "gamerule.category.better-bats.better_bats" โ
โ โ โ
โ โผ [Step 1: Prefix Stripping] โ
โ Strip "gamerule.category." โโ> "better-bats.better_bats" โ
โ โ โ
โ โผ [Step 2: Namespace & Path Separation] โ
โ Separate namespace "better-bats" and path "better_bats" โ
โ โ โ
โ โผ [Step 3: Redundancy Normalization] โ
โ Compare normalized strings: "betterbats" == "betterbats" โ
โ Deduplicate to single segment: "better_bats" โ
โ โ โ
โ โผ [Step 4: Delimiter Splitting & Capitalization] โ
โ Split by "[_-]" โโ> ["better", "bats"] โ
โ Capitalize words โโ> ["Better", "Bats"] โ
โ โ โ
โ โผ [Step 5: String Join] โ
โ Output Display Title: "Better Bats" โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
| Raw GameRule Category Key | Transformed Display Label | Transformation Notes |
|---|---|---|
gamerule.category.better-bats.better_bats |
Better Bats | Deduplicates redundant namespace and path. |
gamerule.category.minecraft.spawning |
Spawning | Drops the default minecraft namespace. |
gamerule.category.social_mobs.wolf_pack |
Social Mobs Wolf Pack | Combines distinct namespace and path segments. |
gamerule.category.custom_rules |
Custom Rules | Replaces underscores with spaces and capitalizes. |
gamerule.category.instant-gratification.ore-multiplier |
Instant Gratification Ore Multiplier | Splits hyphens and capitalizes all words. |
public static String prettifyCategoryKey(String key) {
if (key == null) {
return "";
}
String name = key;
if (name.startsWith("gamerule.category.")) {
name = name.substring("gamerule.category.".length());
}
// Split namespace and path if dot is present
int dotIndex = name.indexOf('.');
if (dotIndex != -1) {
String ns = name.substring(0, dotIndex);
String path = name.substring(dotIndex + 1);
// If the namespace is "minecraft", just drop it
if (ns.equals("minecraft")) {
name = path;
} else {
// Normalize for comparison
String normNs = ns.replace("-", "").replace("_", "").toLowerCase(Locale.ROOT);
String normPath = path.replace("-", "").replace("_", "").toLowerCase(Locale.ROOT);
if (normPath.contains(normNs) || normNs.contains(normPath)) {
name = path; // Use the path part since it's more specific or includes namespace
} else {
name = ns + " " + path;
}
}
}
// Split by underscore or dash
String[] parts = name.split("[_-]");
List<String> words = new ArrayList<>();
for (String part : parts) {
if (part.isEmpty()) {
continue;
}
String capitalized = part.substring(0, 1).toUpperCase(Locale.ROOT) + part.substring(1);
words.add(capitalized);
}
return String.join(" ", words);
}
Collapsible Game Rules โข Built & Maintained by Dasik (Rifaditya)
Released under the GNU General Public License v3.0 (GPL-3.0-or-later)
GitHub Repository โข Modrinth โข CurseForge โข Issue Tracker
๐ Repository Source Disclaimer: The documentation in this Wiki reflects the current source code state in the repository, which may include recent unreleased commits or developmental features ahead of public release builds on CurseForge and Modrinth.
- ๐๏ธ Collapsible Categories
- ๐ Global Actions & Bulk Toggles
- ๐ Smart Search Integration
- โจ๏ธ Keyboard Navigation & Accessibility
- ๐ง State Persistence & JSON Config
- โจ Category Prettification & Naming
- ๐๏ธ Game Rule Presets & Widgets
- ๐ GameRules Reference Table
- ๐ฌ Brigadier Commands & Absence Scope
- ๐ Advancements & Absence Scope
- ๐ฅ๏ธ HUD, Diagnostics & Rendering
- ๐ ๏ธ Developer Setup & Gradle Builds
- ๐งฉ Architecture & Mixin Subsystem
- ๐ DasikLibrary API Integration