Skip to content

Commit 54e615e

Browse files
committed
adventure: Expose the game's ComponentFlattener
1 parent 70389cd commit 54e615e

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/main/java/org/spongepowered/api/adventure/SpongeComponents.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import net.kyori.adventure.audience.Audience;
2828
import net.kyori.adventure.text.Component;
2929
import net.kyori.adventure.text.event.ClickEvent;
30+
import net.kyori.adventure.text.flattener.ComponentFlattener;
3031
import org.spongepowered.api.Sponge;
3132
import org.spongepowered.api.command.CommandCause;
3233
import org.spongepowered.api.registry.DefaultedRegistryReference;
@@ -99,6 +100,17 @@ public static Component resolve(
99100
return SpongeComponents.factory().render(component, senderContext, resolver, otherResolvers);
100101
}
101102

103+
/**
104+
* Get a {@link ComponentFlattener} with access to server-specific information
105+
*
106+
* <p>This flattener can be used for custom formats where translatable strings should be localized server-side.</p>
107+
*
108+
* @return The flattener
109+
*/
110+
public static ComponentFlattener flattener() {
111+
return SpongeComponents.factory().flattener();
112+
}
113+
102114
private static Factory factory() {
103115
return Sponge.game().factoryProvider().provide(Factory.class);
104116
}
@@ -123,5 +135,7 @@ Component render(
123135
final DefaultedRegistryReference<ResolveOperation>... otherResolvers
124136
);
125137

138+
ComponentFlattener flattener();
139+
126140
}
127141
}

0 commit comments

Comments
 (0)