|
| 1 | +package com.thepinkhacker.commandsplus.data.lang; |
| 2 | + |
| 3 | +import com.thepinkhacker.commandsplus.world.GameRuleManager; |
| 4 | +import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; |
| 5 | +import net.fabricmc.fabric.api.datagen.v1.provider.FabricLanguageProvider; |
| 6 | +import net.minecraft.registry.RegistryWrapper; |
| 7 | +import net.minecraft.world.GameRules; |
| 8 | + |
| 9 | +import java.util.concurrent.CompletableFuture; |
| 10 | + |
| 11 | +public class LanguageProvider extends FabricLanguageProvider { |
| 12 | + public LanguageProvider(FabricDataOutput dataOutput, CompletableFuture<RegistryWrapper.WrapperLookup> registryLookup) { |
| 13 | + super(dataOutput, registryLookup); |
| 14 | + } |
| 15 | + |
| 16 | + @Override |
| 17 | + public void generateTranslations(RegistryWrapper.WrapperLookup lookup, TranslationBuilder builder) { |
| 18 | + addGamerule( |
| 19 | + builder, |
| 20 | + GameRuleManager.DO_ENDERMAN_PICKUP, |
| 21 | + "Do Enderman Pickup", |
| 22 | + "Allow Endermen to pickup blocks." |
| 23 | + ); |
| 24 | + addGamerule( |
| 25 | + builder, |
| 26 | + GameRuleManager.DO_ENDERMAN_PLACE, |
| 27 | + "Do Enderman Place", |
| 28 | + "Allow Endermen to place blocks." |
| 29 | + ); |
| 30 | + addGamerule( |
| 31 | + builder, |
| 32 | + GameRuleManager.ITEM_DESPAWN_AGE, |
| 33 | + "Item Despawn Age", |
| 34 | + "Controls how long it takes for an item to despawn." |
| 35 | + ); |
| 36 | + |
| 37 | + GenericTranslationBuilder.of(builder) |
| 38 | + .child(GenericTranslationBuilder.Node.of("commands") |
| 39 | + .child(GenericTranslationBuilder.Node.of("clearspawnpoint") |
| 40 | + .child("failed", "Failed to clear spawnpoint") |
| 41 | + .child("success", "Cleared spawnpoint of %s player(s)") |
| 42 | + ) |
| 43 | + .child(GenericTranslationBuilder.Node.of("cpride") |
| 44 | + .child(GenericTranslationBuilder.Node.of("evict_riders") |
| 45 | + .child("failed", "Failed to evict rider(s)") |
| 46 | + .child("success", "Evicted rider(s)") |
| 47 | + ) |
| 48 | + .child(GenericTranslationBuilder.Node.of("start_riding") |
| 49 | + .child("failed", "Failed to ride the entity") |
| 50 | + .child("success", "Mounted entities") |
| 51 | + ) |
| 52 | + .child(GenericTranslationBuilder.Node.of("stop_riding") |
| 53 | + .child("failed", "Failed to dismount the entity") |
| 54 | + .child("success", "Dismounted entities") |
| 55 | + ) |
| 56 | + .child(GenericTranslationBuilder.Node.of("summon_ride") |
| 57 | + .child("failed", "Failed to summon a ride") |
| 58 | + .child("success", "Summoned and mounted to a %s") |
| 59 | + ) |
| 60 | + .child(GenericTranslationBuilder.Node.of("summon_rider") |
| 61 | + .child("failed", "Failed to summon a rider") |
| 62 | + .child("success", "Summoned and mounted a %s") |
| 63 | + ) |
| 64 | + ) |
| 65 | + .child(GenericTranslationBuilder.Node.of("cpstop") |
| 66 | + .child(GenericTranslationBuilder.Node.of("cancel") |
| 67 | + .child("failed", "Failed to cancel server stop") |
| 68 | + .child("success", "Canceled server stop") |
| 69 | + ) |
| 70 | + .child("immediate", "Stopping server now") |
| 71 | + .child("stop", "Stopped server") |
| 72 | + .child("time", "Stopping server in %s second(s)...") |
| 73 | + ) |
| 74 | + .child(GenericTranslationBuilder.Node.of("daylock") |
| 75 | + .child("enabled", "Enabled daylock") |
| 76 | + .child("disabled", "Disabled daylock") |
| 77 | + ) |
| 78 | + .child(GenericTranslationBuilder.Node.of("gamerulepreset") |
| 79 | + .child(GenericTranslationBuilder.Node.of("load") |
| 80 | + .child("changed", "Changed gamerule %s: %s -> %s") |
| 81 | + .child("failed", "Failed to load gamerule preset: %s") |
| 82 | + .child("unchanged", "No gamerules were affected by: %s") |
| 83 | + .child("success", "Loaded gamerule preset: %s") |
| 84 | + ) |
| 85 | + .child(GenericTranslationBuilder.Node.of("save") |
| 86 | + .child("success", "Saved gamerule preset: %s") |
| 87 | + ) |
| 88 | + ) |
| 89 | + .child(GenericTranslationBuilder.Node.of("head") |
| 90 | + .child(GenericTranslationBuilder.Node.of("give") |
| 91 | + .child("failed", "Failed to give head to player") |
| 92 | + .child("success", "Gave head to player") |
| 93 | + ) |
| 94 | + .child(GenericTranslationBuilder.Node.of("query") |
| 95 | + .child(GenericTranslationBuilder.Node.of("name") |
| 96 | + .child("success", "The head belongs to %s") |
| 97 | + ) |
| 98 | + .child(GenericTranslationBuilder.Node.of("uuid") |
| 99 | + .child("success", "The head's owner's UUID is %s") |
| 100 | + ) |
| 101 | + ) |
| 102 | + ) |
| 103 | + .child(GenericTranslationBuilder.Node.of("health") |
| 104 | + .child(GenericTranslationBuilder.Node.of("add") |
| 105 | + .child("failed", "Failed to add health") |
| 106 | + .child("success", "Added %s health") |
| 107 | + ) |
| 108 | + .child(GenericTranslationBuilder.Node.of("query") |
| 109 | + .child("failed", "Failed to query health") |
| 110 | + .child("success", "Health is %s") |
| 111 | + ) |
| 112 | + .child(GenericTranslationBuilder.Node.of("set") |
| 113 | + .child("failed", "Failed to set health") |
| 114 | + .child("success", "Set health to %s") |
| 115 | + ) |
| 116 | + ) |
| 117 | + .child(GenericTranslationBuilder.Node.of("hunger") |
| 118 | + .child(GenericTranslationBuilder.Node.of("add") |
| 119 | + .child(GenericTranslationBuilder.Node.of("exhaustion") |
| 120 | + .child("failed", "Failed to add exhaustion") |
| 121 | + .child("success", "Added %s exhaustion") |
| 122 | + ) |
| 123 | + .child(GenericTranslationBuilder.Node.of("food") |
| 124 | + .child("failed", "Failed to add food") |
| 125 | + .child("success", "Added %s food") |
| 126 | + ) |
| 127 | + .child(GenericTranslationBuilder.Node.of("saturation") |
| 128 | + .child("failed", "Failed to add saturation") |
| 129 | + .child("success", "Added %s saturation") |
| 130 | + ) |
| 131 | + ) |
| 132 | + .child(GenericTranslationBuilder.Node.of("query") |
| 133 | + .child(GenericTranslationBuilder.Node.of("exhaustion") |
| 134 | + .child("failed", "Failed to query exhaustion") |
| 135 | + .child("success", "Player's exhaustion is %s") |
| 136 | + ) |
| 137 | + .child(GenericTranslationBuilder.Node.of("food") |
| 138 | + .child("failed", "Failed to query food") |
| 139 | + .child("success", "Player's food is %s") |
| 140 | + ) |
| 141 | + .child(GenericTranslationBuilder.Node.of("saturation") |
| 142 | + .child("failed", "Failed to query saturation") |
| 143 | + .child("success", "Player's saturation is %s") |
| 144 | + ) |
| 145 | + ) |
| 146 | + .child(GenericTranslationBuilder.Node.of("set") |
| 147 | + .child(GenericTranslationBuilder.Node.of("exhaustion") |
| 148 | + .child("failed", "Failed to set exhaustion") |
| 149 | + .child("success", "Set exhaustion to %s") |
| 150 | + ) |
| 151 | + .child(GenericTranslationBuilder.Node.of("food") |
| 152 | + .child("failed", "Failed to set food") |
| 153 | + .child("success", "Set food to %s") |
| 154 | + ) |
| 155 | + .child(GenericTranslationBuilder.Node.of("saturation") |
| 156 | + .child("failed", "Failed to set saturation") |
| 157 | + .child("success", "Set saturation to %s") |
| 158 | + ) |
| 159 | + ) |
| 160 | + ) |
| 161 | + .child(GenericTranslationBuilder.Node.of("name") |
| 162 | + .child(GenericTranslationBuilder.Node.of("entity") |
| 163 | + .child("failed", "Failed to name entity") |
| 164 | + // TODO: Color name |
| 165 | + .child("success", "Named entity to \"%s\"") |
| 166 | + ) |
| 167 | + .child(GenericTranslationBuilder.Node.of("item") |
| 168 | + .child("failed", "Failed to name item") |
| 169 | + // TODO: Color name |
| 170 | + .child("success", "Named item to \"%s\"") |
| 171 | + ) |
| 172 | + ) |
| 173 | + .child(GenericTranslationBuilder.Node.of("setowner") |
| 174 | + .child("failed", "Failed to set pet's owner") |
| 175 | + .child("success", "Set pet's owner to %s") |
| 176 | + ) |
| 177 | + .child(GenericTranslationBuilder.Node.of("toggledownfall") |
| 178 | + .child("success", "Toggled downfall") |
| 179 | + ) |
| 180 | + ) |
| 181 | + .build(); |
| 182 | + } |
| 183 | + |
| 184 | + private static void addGamerule( |
| 185 | + TranslationBuilder builder, |
| 186 | + GameRules.Key<?> gamerule, |
| 187 | + String title, |
| 188 | + String description |
| 189 | + ) { |
| 190 | + addGamerule(builder, gamerule, title); |
| 191 | + builder.add(gamerule.getTranslationKey() + ".description", description); |
| 192 | + } |
| 193 | + |
| 194 | + private static void addGamerule(TranslationBuilder builder, GameRules.Key<?> gamerule, String title) { |
| 195 | + builder.add(gamerule.getTranslationKey(), title); |
| 196 | + } |
| 197 | +} |
0 commit comments