Properly use platform chat listeners (#152)

This commit is contained in:
Josua Parks authored and GitHub committed 2021-05-30 10:37:41 -07:00
1 parent f1a469033b
commit 4440bf414f
11 files changed
+132 -113

No files matched your search

@@ -1,7 +1,10 @@
package net.draycia.carbon.api.channels;
import java.util.List;
import java.util.Set;
import net.draycia.carbon.api.users.CarbonPlayer;
import net.draycia.carbon.api.util.ChatComponentRenderer;
import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.key.Keyed;
import net.kyori.adventure.text.Component;
import org.checkerframework.checker.nullness.qual.NonNull;
@@ -30,11 +33,30 @@ public interface ChatChannel extends Keyed, ChatComponentRenderer {
/**
* Checks if the player may receive messages from this channel.
*
* @param carbonPlayer the player that's receiving messages
* @param audience the audience that's receiving messages
* @return if the player may receive messages
* @since 2.0.0
*/
ChannelPermissionResult hearingPermitted(final CarbonPlayer carbonPlayer);
ChannelPermissionResult hearingPermitted(final Audience audience);
/**
* Returns a list of all recipients that will receive messages from the sender.
*
* @param sender the sender of messages
* @return the recipients
* @since 2.0.0
*/
List<Audience> recipients(final CarbonPlayer sender);
/**
* Filters the given recipients and removes entries that may not see messages in this channel.
*
* @param sender the sender of messages
* @param recipients the recipients
* @return the recipients that may receive messages
* @since 2.0.0
*/
Set<Audience> filterRecipients(final CarbonPlayer sender, final Set<Audience> recipients);
/**
* Represents the result of a channel permission check.
@@ -4,7 +4,6 @@ import net.draycia.carbon.api.users.CarbonPlayer;
import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.text.Component;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.checkerframework.framework.qual.DefaultQualifier;
/**
@@ -25,10 +24,10 @@ public interface ChatComponentRenderer {
* @param message the message being sent
* @param originalMessage the original message that was sent
* @return the component to be shown to the recipient,
* or null if the recipient should not receive the message
* or empty if the recipient should not receive the message
* @since 2.0.0
*/
@Nullable
@NonNull
Component render(final CarbonPlayer sender,
final Audience recipient,
final Component message,
@@ -8,6 +8,7 @@ import net.kyori.adventure.text.Component;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.checkerframework.framework.qual.DefaultQualifier;
import org.jetbrains.annotations.NotNull;
/**
* A chat renderer that's identifiable by key.
@@ -37,7 +38,7 @@ public interface KeyedRenderer extends Keyed, ChatComponentRenderer {
record Impl(@NonNull Key key, ChatComponentRenderer renderer) implements KeyedRenderer {
@Override
public @Nullable
public @Nullable @NotNull
Component render(
final CarbonPlayer sender,
final Audience recipient,