Skip to content

Commit

Permalink
Add SpongeComponents#receiverVirtualComponent
Browse files Browse the repository at this point in the history
  • Loading branch information
aromaa committed Feb 4, 2025
1 parent 2781035 commit c4ed14f
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,16 @@

import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.ComponentLike;
import net.kyori.adventure.text.VirtualComponent;
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;

import java.util.function.Consumer;
import java.util.function.Function;

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

/**
* Creates a new {@link VirtualComponent} that will be used to
* render each {@link Audience} their own version of
* the received message.
*
* @return The virtual component
*/
public static VirtualComponent receiverVirtualComponent(final Function<Audience, ComponentLike> apply) {
return SpongeComponents.factory().receiverVirtualComponent(apply);
}

private static Factory factory() {
return Sponge.game().factoryProvider().provide(Factory.class);
}
Expand All @@ -137,5 +151,6 @@ Component render(

ComponentFlattener flattener();

VirtualComponent receiverVirtualComponent(Function<Audience, ComponentLike> apply);
}
}

0 comments on commit c4ed14f

Please sign in to comment.