mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-01 14:38:48 +00:00
Add support for per-channel mutes
This commit is contained in:
1 parent
befce62375
commit
a57cd5c103
13 files changed
+137
-48
No files matched your search
@@ -1,6 +1,8 @@
|
||||
package net.draycia.carbon.api.events;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.draycia.carbon.api.channels.ChatChannel;
|
||||
import net.draycia.carbon.api.users.CarbonPlayer;
|
||||
import net.draycia.carbon.api.util.KeyedRenderer;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
@@ -22,6 +24,7 @@ public class CarbonChatEvent implements ResultedCarbonEvent<CarbonChatEvent.Resu
|
||||
private final CarbonPlayer sender;
|
||||
private final Component originalMessage;
|
||||
private final List<? extends Audience> recipients;
|
||||
private final ChatChannel chatChannel;
|
||||
private Component message;
|
||||
private Result result = Result.ALLOWED;
|
||||
|
||||
@@ -32,19 +35,22 @@ public class CarbonChatEvent implements ResultedCarbonEvent<CarbonChatEvent.Resu
|
||||
* @param originalMessage the original message that was sent
|
||||
* @param recipients the recipients of the message
|
||||
* @param renderers the renderers of the message
|
||||
* @param chatChannel the channel the message was sent in
|
||||
* @since 2.0.0
|
||||
*/
|
||||
public CarbonChatEvent(
|
||||
final CarbonPlayer sender,
|
||||
final Component originalMessage,
|
||||
final List<? extends Audience> recipients,
|
||||
final List<KeyedRenderer> renderers
|
||||
) {
|
||||
final List<KeyedRenderer> renderers,
|
||||
final ChatChannel chatChannel
|
||||
) {
|
||||
this.sender = sender;
|
||||
this.originalMessage = originalMessage;
|
||||
this.message = originalMessage;
|
||||
this.recipients = recipients;
|
||||
this.renderers = renderers;
|
||||
this.chatChannel = chatChannel;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -97,6 +103,16 @@ public class CarbonChatEvent implements ResultedCarbonEvent<CarbonChatEvent.Resu
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
/**
|
||||
* The chat channel the message was sent in.
|
||||
*
|
||||
* @return the chat channel
|
||||
* @since 2.0.0
|
||||
*/
|
||||
public ChatChannel chatChannel() {
|
||||
return this.chatChannel;
|
||||
}
|
||||
|
||||
/**
|
||||
* The recipients of the message.
|
||||
* List is mutable and elements may be added/removed.
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.UUID;
|
||||
import net.draycia.carbon.api.channels.ChatChannel;
|
||||
import net.draycia.carbon.api.users.punishments.MuteEntry;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.identity.Identified;
|
||||
import net.kyori.adventure.text.Component;
|
||||
@@ -144,19 +145,31 @@ public interface CarbonPlayer extends Audience, Identified {
|
||||
List<String> groups();
|
||||
|
||||
/**
|
||||
* Returns if the player is muted and unable to speak in chat.
|
||||
* The mute entries the player has.
|
||||
*
|
||||
* @return if the player is muted
|
||||
* @return the player's mute entries
|
||||
* @since 2.0.0
|
||||
*/
|
||||
boolean muted();
|
||||
List<MuteEntry> muteEntries();
|
||||
|
||||
/**
|
||||
* Mutes and unmutes the player.
|
||||
* Returns if the player is muted for the channel and unable to speak in it.
|
||||
*
|
||||
* @param chatChannel the chat channel
|
||||
* @return if the player is muted in the channel
|
||||
* @since 2.0.0
|
||||
*/
|
||||
void muted(final boolean muted);
|
||||
boolean muted(final ChatChannel chatChannel);
|
||||
|
||||
/**
|
||||
* Mutes and unmutes the player for the specified channel.
|
||||
*
|
||||
* @param chatChannel the channel to mute/unmute for
|
||||
* @param muted if the player should be muted for the channel
|
||||
* @param cause the UUID of the cause of the mute, typically a player UUID
|
||||
* @since 2.0.0
|
||||
*/
|
||||
void muted(final ChatChannel chatChannel, final boolean muted, final @Nullable UUID cause);
|
||||
|
||||
/**
|
||||
* Returns if the player is deafened and unable to read messages.
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package net.draycia.carbon.api.users.punishments;
|
||||
|
||||
import net.kyori.adventure.key.Key;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@DefaultQualifier(NonNull.class)
|
||||
public record MuteEntry(long muteEpoch, @Nullable UUID muteCause, long expirationEpoch, @Nullable Key channel) {
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user