mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-01 22:15:08 +00:00
Overhaul mute feature and add mute commands (#156)
and other stuff lmao
This commit is contained in:
1 parent
3ba3dfc6e9
commit
de118017eb
31 files changed
+813
-136
No files matched your search
@@ -2,6 +2,7 @@ package net.draycia.carbon.api.users;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
import net.draycia.carbon.api.channels.ChatChannel;
|
||||
import net.draycia.carbon.api.users.punishments.MuteEntry;
|
||||
@@ -20,6 +21,16 @@ import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
@DefaultQualifier(NonNull.class)
|
||||
public interface CarbonPlayer extends Audience, Identified {
|
||||
|
||||
static Component renderName(final CarbonPlayer player) {
|
||||
if (player.temporaryDisplayName() != null && player.temporaryDisplayNameExpiration() > System.currentTimeMillis()) {
|
||||
return Objects.requireNonNull(player.temporaryDisplayName());
|
||||
} else if (player.hasCustomDisplayName()) {
|
||||
return Objects.requireNonNull(player.displayName());
|
||||
} else {
|
||||
return Component.text(player.username());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the player's username.
|
||||
*
|
||||
@@ -145,9 +156,9 @@ public interface CarbonPlayer extends Audience, Identified {
|
||||
List<String> groups();
|
||||
|
||||
/**
|
||||
* The mute entries the player has.
|
||||
* A copy of the mute entries the player has.
|
||||
*
|
||||
* @return the player's mute entries
|
||||
* @return a copy of the player's mute entries
|
||||
* @since 2.0.0
|
||||
*/
|
||||
List<MuteEntry> muteEntries();
|
||||
@@ -167,9 +178,17 @@ public interface CarbonPlayer extends Audience, Identified {
|
||||
* @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
|
||||
* @param duration the duration of the mute, or -1 if it does not expire
|
||||
* @param reason the reason the player was muted
|
||||
* @since 2.0.0
|
||||
*/
|
||||
void muted(final ChatChannel chatChannel, final boolean muted, final @Nullable UUID cause);
|
||||
@Nullable MuteEntry addMuteEntry(
|
||||
final @Nullable ChatChannel chatChannel,
|
||||
final boolean muted,
|
||||
final @Nullable UUID cause,
|
||||
final long duration,
|
||||
final @Nullable String reason
|
||||
);
|
||||
|
||||
/**
|
||||
* Returns if the player is deafened and unable to read messages.
|
||||
|
||||
@@ -8,7 +8,14 @@ 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) {
|
||||
public record MuteEntry(
|
||||
long muteEpoch,
|
||||
@Nullable UUID muteCause,
|
||||
long expirationEpoch,
|
||||
@Nullable String reason,
|
||||
@Nullable Key channel,
|
||||
UUID muteId
|
||||
) {
|
||||
|
||||
public boolean valid() {
|
||||
return System.currentTimeMillis() < expirationEpoch;
|
||||
|
||||
@@ -1,11 +1,20 @@
|
||||
package net.draycia.carbon.api.util;
|
||||
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.audience.ForwardingAudience;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public record SourcedAudience(Audience sender, Audience recipient) {
|
||||
public record SourcedAudience(Audience sender, Audience recipient) implements ForwardingAudience.Single {
|
||||
|
||||
public static final SourcedAudience EMPTY = new SourcedAudience(Audience.empty(), Audience.empty());
|
||||
|
||||
public static SourcedAudience empty() {
|
||||
return new SourcedAudience(Audience.empty(), Audience.empty());
|
||||
return EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Audience audience() {
|
||||
return Audience.audience(sender, recipient);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user