adventure: Expose the game's ComponentFlattener
import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.event.ClickEvent;
+import net.kyori.adventure.text.flattener.ComponentFlattener;
import org.spongepowered.api.Sponge;
import org.spongepowered.api.command.CommandCause;
import org.spongepowered.api.registry.DefaultedRegistryReference;
@@ -99,6 +100,17 @@ public static Component resolve(
return SpongeComponents.factory().render(component, senderContext, resolver, otherResolvers);
}
+ /**
+ * Get a {@link ComponentFlattener} with access to server-specific information
+ *
+ * <p>This flattener can be used for custom formats where translatable strings should be localized server-side.</p>
+ *
+ * @return The flattener
+ */
+ public static ComponentFlattener flattener() {
+ return SpongeComponents.factory().flattener();
+ }
+
private static Factory factory() {
return Sponge.game().factoryProvider().provide(Factory.class);
}
@@ -123,5 +135,7 @@ Component render(
final DefaultedRegistryReference<ResolveOperation>... otherResolvers
);
+ ComponentFlattener flattener();
+
}
}
