Skip to content

Commit c4ed14f

Browse files
committed
Add SpongeComponents#receiverVirtualComponent
1 parent 2781035 commit c4ed14f

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,16 @@
2626

2727
import net.kyori.adventure.audience.Audience;
2828
import net.kyori.adventure.text.Component;
29+
import net.kyori.adventure.text.ComponentLike;
30+
import net.kyori.adventure.text.VirtualComponent;
2931
import net.kyori.adventure.text.event.ClickEvent;
3032
import net.kyori.adventure.text.flattener.ComponentFlattener;
3133
import org.spongepowered.api.Sponge;
3234
import org.spongepowered.api.command.CommandCause;
3335
import org.spongepowered.api.registry.DefaultedRegistryReference;
3436

3537
import java.util.function.Consumer;
38+
import java.util.function.Function;
3639

3740
/**
3841
* Additional SpongeAPI-specific methods for working with {@link Component}s and related.
@@ -111,6 +114,17 @@ public static ComponentFlattener flattener() {
111114
return SpongeComponents.factory().flattener();
112115
}
113116

117+
/**
118+
* Creates a new {@link VirtualComponent} that will be used to
119+
* render each {@link Audience} their own version of
120+
* the received message.
121+
*
122+
* @return The virtual component
123+
*/
124+
public static VirtualComponent receiverVirtualComponent(final Function<Audience, ComponentLike> apply) {
125+
return SpongeComponents.factory().receiverVirtualComponent(apply);
126+
}
127+
114128
private static Factory factory() {
115129
return Sponge.game().factoryProvider().provide(Factory.class);
116130
}
@@ -137,5 +151,6 @@ Component render(
137151

138152
ComponentFlattener flattener();
139153

154+
VirtualComponent receiverVirtualComponent(Function<Audience, ComponentLike> apply);
140155
}
141156
}

0 commit comments

Comments
 (0)