simplify mute command

This commit is contained in:
Draycia committed 2021-11-30 23:34:15 -08:00
1 parent e20bc2a4bb
commit 50e4f00ecd
23 files changed
+92 -366

No files matched your search

@@ -24,7 +24,6 @@ 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;
import net.draycia.carbon.api.util.InventorySlot;
import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.identity.Identified;
@@ -195,40 +194,20 @@ public interface CarbonPlayer extends Audience, Identified {
List<String> groups();
/**
* A copy of the mute entries the player has.
* Returns if the player is muted.
*
* @return a copy of the player's mute entries
* @return if the player is muted
* @since 2.0.0
*/
// TODO: ensure this never returns expired entries
List<MuteEntry> muteEntries();
boolean muted();
/**
* Returns if the player is muted for the channel and unable to speak in it.
* Mutes and unmutes the player.
*
* @param chatChannel the chat channel
* @return if the player is muted in the channel
* @param muted if the player is now muted
* @since 2.0.0
*/
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
* @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
*/
@Nullable MuteEntry addMuteEntry(
final @Nullable ChatChannel chatChannel,
final boolean muted,
final @Nullable UUID cause,
final long duration,
final @Nullable String reason
);
void muted(boolean muted);
/**
* Checks if the sender is being ignored by this player.
@@ -1,53 +0,0 @@
/*
* CarbonChat
*
* Copyright (c) 2021 Josua Parks (Vicarious)
* Contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.draycia.carbon.api.users.punishments;
import java.util.UUID;
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;
/**
* An entry describing when and why and how a player was muted.
*
* @since 2.0.0
*/
@DefaultQualifier(NonNull.class)
public record MuteEntry(
long muteEpoch,
@Nullable UUID muteCause,
long expirationEpoch,
@Nullable String reason,
@Nullable Key channel,
UUID muteId
) {
/**
* Returns if this entry is still active and should be enforced.
*
* @return if this entry is still valid
* @since 2.0.0
*/
public boolean valid() {
return this.expirationEpoch == -1 || System.currentTimeMillis() < this.expirationEpoch;
}
}