Skip to content

Commit 495986e

Browse files
committed
Merge branch 'api-14' into api-14-consume-effects
2 parents 24162fe + 356e1fa commit 495986e

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

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

+5
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ public final class ResolveOperations {
6868
*/
6969
public static final DefaultedRegistryReference<ResolveOperation> CUSTOM_TRANSLATIONS = ResolveOperations.key(ResourceKey.sponge("custom_translations"));
7070

71+
/**
72+
* Resolves Sponge provided virtual components.
73+
*/
74+
public static final DefaultedRegistryReference<ResolveOperation> VIRTUAL_COMPONENTS = ResolveOperations.key(ResourceKey.sponge("virtual_components"));
75+
7176
// SORTFIELDS:OFF
7277
// @formatter:ON
7378

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

+20-2
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,28 @@ public static ComponentFlattener flattener() {
119119
* render each {@link Audience} their own version of
120120
* the received message.
121121
*
122+
* @param apply The function invoked to render
123+
* {@link Audience} specific component.
122124
* @return The virtual component
123125
*/
124126
public static VirtualComponent receiverVirtualComponent(final Function<Audience, ComponentLike> apply) {
125-
return SpongeComponents.factory().receiverVirtualComponent(apply);
127+
return SpongeComponents.receiverVirtualComponent(apply, "");
128+
}
129+
130+
/**
131+
* Creates a new {@link VirtualComponent} that will be used to
132+
* render each {@link Audience} their own version of
133+
* the received message.
134+
*
135+
* @param apply The function invoked to render
136+
* {@link Audience} specific component.
137+
* @param fallbackValue The fallback value used when this
138+
* component has been serialized without
139+
* being rendered.
140+
* @return The virtual component
141+
*/
142+
public static VirtualComponent receiverVirtualComponent(final Function<Audience, ComponentLike> apply, final String fallbackValue) {
143+
return SpongeComponents.factory().receiverVirtualComponent(apply, fallbackValue);
126144
}
127145

128146
private static Factory factory() {
@@ -151,6 +169,6 @@ Component render(
151169

152170
ComponentFlattener flattener();
153171

154-
VirtualComponent receiverVirtualComponent(Function<Audience, ComponentLike> apply);
172+
VirtualComponent receiverVirtualComponent(Function<Audience, ComponentLike> apply, String fallbackValue);
155173
}
156174
}

0 commit comments

Comments
 (0)