Skip to content

Commit

Permalink
Use updated translation keys in commands/command arguments (#227)
Browse files Browse the repository at this point in the history
  • Loading branch information
jpenilla authored Nov 1, 2023
1 parent 0067946 commit c2229a3
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

public class EnumArgument<T extends Enum<T>> implements ArgumentType<T> {
private static final Dynamic2CommandExceptionType INVALID_ENUM = new Dynamic2CommandExceptionType(
(found, constants) -> Component.translatable("commands.forge.arguments.enum.invalid", constants, found));
(found, constants) -> Component.translatable("commands.neoforge.arguments.enum.invalid", constants, found));
private final Class<T> enumClass;

public static <R extends Enum<R>> EnumArgument<R> enumArgument(Class<R> enumClass) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ModListCommand {
return Commands.literal("mods")
.requires(cs -> cs.hasPermission(0)) //permission
.executes(ctx -> {
ctx.getSource().sendSuccess(() -> Component.translatable("commands.forge.mods.list",
ctx.getSource().sendSuccess(() -> Component.translatable("commands.neoforge.mods.list",
ModList.get().applyForEachModFile(modFile ->
// locator - filename : firstmod (version) - numberofmods\n
String.format(Locale.ROOT, "%s %s : %s (%s) - %d",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class TPSCommand {
@SuppressWarnings("resource")
double meanTickTime = mean(ctx.getSource().getServer().tickTimes) * 1.0E-6D;
double meanTPS = Math.min(1000.0 / meanTickTime, 20);
ctx.getSource().sendSuccess(() -> Component.translatable("commands.forge.tps.summary.all", TIME_FORMATTER.format(meanTickTime), TIME_FORMATTER.format(meanTPS)), false);
ctx.getSource().sendSuccess(() -> Component.translatable("commands.neoforge.tps.summary.all", TIME_FORMATTER.format(meanTickTime), TIME_FORMATTER.format(meanTPS)), false);

return 0;
});
Expand All @@ -48,7 +48,7 @@ private static int sendTime(CommandSourceStack cs, ServerLevel dim) throws Comma
final Registry<DimensionType> reg = cs.registryAccess().registryOrThrow(Registries.DIMENSION_TYPE);
double worldTickTime = mean(times) * 1.0E-6D;
double worldTPS = Math.min(1000.0 / worldTickTime, 20);
cs.sendSuccess(() -> Component.translatable("commands.forge.tps.summary.named", dim.dimension().location().toString(), reg.getKey(dim.dimensionType()), TIME_FORMATTER.format(worldTickTime), TIME_FORMATTER.format(worldTPS)), false);
cs.sendSuccess(() -> Component.translatable("commands.neoforge.tps.summary.named", dim.dimension().location().toString(), reg.getKey(dim.dimensionType()), TIME_FORMATTER.format(worldTickTime), TIME_FORMATTER.format(worldTPS)), false);

return 1;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ class TagsCommand {
private static final long PAGE_SIZE = 8;
private static final ResourceKey<Registry<Registry<?>>> ROOT_REGISTRY_KEY = ResourceKey.createRegistryKey(new ResourceLocation("root"));

private static final DynamicCommandExceptionType UNKNOWN_REGISTRY = new DynamicCommandExceptionType(key -> Component.translatable("commands.forge.tags.error.unknown_registry", key));
private static final Dynamic2CommandExceptionType UNKNOWN_TAG = new Dynamic2CommandExceptionType((tag, registry) -> Component.translatable("commands.forge.tags.error.unknown_tag", tag, registry));
private static final Dynamic2CommandExceptionType UNKNOWN_ELEMENT = new Dynamic2CommandExceptionType((tag, registry) -> Component.translatable("commands.forge.tags.error.unknown_element", tag, registry));
private static final DynamicCommandExceptionType UNKNOWN_REGISTRY = new DynamicCommandExceptionType(key -> Component.translatable("commands.neoforge.tags.error.unknown_registry", key));
private static final Dynamic2CommandExceptionType UNKNOWN_TAG = new Dynamic2CommandExceptionType((tag, registry) -> Component.translatable("commands.neoforge.tags.error.unknown_tag", tag, registry));
private static final Dynamic2CommandExceptionType UNKNOWN_ELEMENT = new Dynamic2CommandExceptionType((tag, registry) -> Component.translatable("commands.neoforge.tags.error.unknown_element", tag, registry));

public static ArgumentBuilder<CommandSourceStack, ?> register() {
/*
Expand Down Expand Up @@ -99,9 +99,9 @@ private static int listTags(final CommandContext<CommandSourceStack> ctx, final
final long tagCount = registry.getTags().count();

ctx.getSource().sendSuccess(() -> createMessage(
Component.translatable("commands.forge.tags.registry_key", Component.literal(registryKey.location().toString()).withStyle(ChatFormatting.GOLD)),
"commands.forge.tags.tag_count",
"commands.forge.tags.copy_tag_names",
Component.translatable("commands.neoforge.tags.registry_key", Component.literal(registryKey.location().toString()).withStyle(ChatFormatting.GOLD)),
"commands.neoforge.tags.tag_count",
"commands.neoforge.tags.copy_tag_names",
tagCount,
page,
ChatFormatting.DARK_GREEN,
Expand All @@ -126,11 +126,11 @@ private static int listTagElements(final CommandContext<CommandSourceStack> ctx,
.orElseThrow(() -> UNKNOWN_TAG.create(tagKey.location(), registryKey.location()));

ctx.getSource().sendSuccess(() -> createMessage(
Component.translatable("commands.forge.tags.tag_key",
Component.translatable("commands.neoforge.tags.tag_key",
Component.literal(tagKey.registry().location().toString()).withStyle(ChatFormatting.GOLD),
Component.literal(tagKey.location().toString()).withStyle(ChatFormatting.DARK_GREEN)),
"commands.forge.tags.element_count",
"commands.forge.tags.copy_element_names",
"commands.neoforge.tags.element_count",
"commands.neoforge.tags.copy_element_names",
tag.size(),
page,
ChatFormatting.YELLOW,
Expand All @@ -154,11 +154,11 @@ private static int queryElementTags(final CommandContext<CommandSourceStack> ctx
final long containingTagsCount = elementHolder.tags().count();

ctx.getSource().sendSuccess(() -> createMessage(
Component.translatable("commands.forge.tags.element",
Component.translatable("commands.neoforge.tags.element",
Component.literal(registryKey.location().toString()).withStyle(ChatFormatting.GOLD),
Component.literal(elementLocation.toString()).withStyle(ChatFormatting.YELLOW)),
"commands.forge.tags.containing_tag_count",
"commands.forge.tags.copy_tag_names",
"commands.neoforge.tags.containing_tag_count",
"commands.neoforge.tags.copy_tag_names",
containingTagsCount,
page,
ChatFormatting.DARK_GREEN,
Expand Down Expand Up @@ -186,7 +186,7 @@ private static MutableComponent createMessage(final MutableComponent header,
.withClickEvent(new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, allElementNames))
.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT,
Component.translatable(copyHoverText)))));
containsComponent = Component.translatable("commands.forge.tags.page_info",
containsComponent = Component.translatable("commands.neoforge.tags.page_info",
containsComponent, actualPage, totalPages);
}

Expand Down

0 comments on commit c2229a3

Please sign in to comment.