mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-01 14:38:48 +00:00
simplify mute command
This commit is contained in:
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;
|
||||
}
|
||||
|
||||
}
|
||||
+1
-1
@@ -57,7 +57,7 @@ public class BukkitPlayerDeathListener implements Listener {
|
||||
|
||||
final CarbonPlayer player = result.player();
|
||||
|
||||
if (!player.muteEntries().isEmpty()) {
|
||||
if (player.muted()) {
|
||||
event.deathMessage(null);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -66,7 +66,7 @@ public class BukkitPlayerJoinListener implements Listener {
|
||||
}
|
||||
|
||||
// Don't show join messages when muted
|
||||
if (this.configFactory.primaryConfig().hideMutedJoinLeaveQuit() && !player.muteEntries().isEmpty()) {
|
||||
if (this.configFactory.primaryConfig().hideMutedJoinLeaveQuit() && player.muted()) {
|
||||
event.joinMessage(null);
|
||||
}
|
||||
}
|
||||
@@ -83,7 +83,7 @@ public class BukkitPlayerJoinListener implements Listener {
|
||||
final CarbonPlayer player = result.player();
|
||||
|
||||
if (this.configFactory.primaryConfig().hideMutedJoinLeaveQuit()) {
|
||||
if (!player.muteEntries().isEmpty()) {
|
||||
if (player.muted()) {
|
||||
event.quitMessage(null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,7 +74,6 @@ public final class BasicChatChannel implements ChatChannel {
|
||||
|
||||
@Override
|
||||
public @Nullable String quickPrefix() {
|
||||
// todo
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -211,8 +211,7 @@ public class CarbonChannelRegistry implements ChannelRegistry, DefaultedRegistry
|
||||
|
||||
loader.save(node);
|
||||
|
||||
// TODO: create advanced-channel.conf.example
|
||||
// TODO: log in console, "no channels found - adding example configs"
|
||||
this.logger.info("No custom channels defined! Using basic handler.");
|
||||
} catch (final IOException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
@@ -242,8 +241,8 @@ public class CarbonChannelRegistry implements ChannelRegistry, DefaultedRegistry
|
||||
.handler(handler -> {
|
||||
final var sender = ((PlayerCommander) handler.getSender()).carbonPlayer();
|
||||
|
||||
if (sender.muted(channel)) {
|
||||
// TODO: "you are muted in this channel!!!!"
|
||||
if (sender.muted()) {
|
||||
this.messageService.muteCannotSpeak(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -50,6 +50,11 @@ public class ContinueCommand {
|
||||
.handler(handler -> {
|
||||
final CarbonPlayer sender = ((PlayerCommander) handler.getSender()).carbonPlayer();
|
||||
|
||||
if (sender.muted()) {
|
||||
messageService.muteCannotSpeak(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
final String message = handler.get("message");
|
||||
final UUID whisperTarget = sender.lastWhisperTarget();
|
||||
|
||||
|
||||
@@ -25,22 +25,17 @@ import com.google.inject.Inject;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
import net.draycia.carbon.api.CarbonChat;
|
||||
import net.draycia.carbon.api.channels.ChatChannel;
|
||||
import net.draycia.carbon.api.users.CarbonPlayer;
|
||||
import net.draycia.carbon.api.users.punishments.MuteEntry;
|
||||
import net.draycia.carbon.common.command.Commander;
|
||||
import net.draycia.carbon.common.command.PlayerCommander;
|
||||
import net.draycia.carbon.common.command.argument.CarbonPlayerArgument;
|
||||
import net.draycia.carbon.common.messages.CarbonMessageService;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
|
||||
@DefaultQualifier(NonNull.class)
|
||||
public class MuteCommand {
|
||||
|
||||
private final CommandManager<Commander> commandManager;
|
||||
|
||||
@Inject
|
||||
public MuteCommand(
|
||||
final CommandManager<Commander> commandManager,
|
||||
@@ -48,8 +43,6 @@ public class MuteCommand {
|
||||
final CarbonChat carbonChat,
|
||||
final CarbonPlayerArgument carbonPlayerArgument
|
||||
) {
|
||||
this.commandManager = commandManager;
|
||||
|
||||
final var command = commandManager.commandBuilder("mute")
|
||||
.argument(carbonPlayerArgument.newInstance(false, "player", CarbonPlayerArgument.NO_SENDER))
|
||||
.flag(commandManager.flagBuilder("uuid")
|
||||
@@ -76,80 +69,21 @@ public class MuteCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
final @Nullable ChatChannel channel = handler.flags().get("channel");
|
||||
final long duration = handler.flags().getValue("duration", -1L);
|
||||
final @Nullable String reason = handler.flags().get("reason");
|
||||
|
||||
// Intentionally directly pass in the flags, they're null if not present
|
||||
final @Nullable MuteEntry muteEntry = target.addMuteEntry(channel, true,
|
||||
target.uuid(), duration, reason);
|
||||
messageService.muteAlertRecipient(target);
|
||||
|
||||
for (final var player : carbonChat.server().players()) {
|
||||
if (!player.equals(sender) && !player.hasPermission("carbon.mute.notify")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
this.sendMuteMessage(messageService, muteEntry, (PlayerCommander) handler.getSender(),
|
||||
sender, target, player);
|
||||
messageService.muteAlertPlayers(player, CarbonPlayer.renderName(target));
|
||||
}
|
||||
|
||||
target.muted(true);
|
||||
})
|
||||
.build();
|
||||
|
||||
commandManager.command(command);
|
||||
}
|
||||
|
||||
private void sendMuteMessage(
|
||||
final CarbonMessageService messageService,
|
||||
final MuteEntry muteEntry,
|
||||
final PlayerCommander playerCommander,
|
||||
final CarbonPlayer sender,
|
||||
final CarbonPlayer target,
|
||||
final CarbonPlayer recipient
|
||||
) {
|
||||
if (target.equals(recipient)) {
|
||||
messageService.playerAlertMuted(target);
|
||||
this.commandManager.executeCommand(playerCommander, "/baninfo -u " + muteEntry.muteId());
|
||||
// TODO: Carbon command names will be user configurable, account for this!
|
||||
}
|
||||
|
||||
// Oh no
|
||||
if (muteEntry.reason() != null && target.hasPermission("carbon.mute.notify.reason")) {
|
||||
if (muteEntry.channel() != null) {
|
||||
if (muteEntry.expirationEpoch() == -1) {
|
||||
messageService.broadcastPlayerChannelMutedPermanentlyReason(recipient, target.username(),
|
||||
sender.username(), muteEntry.reason(), muteEntry.channel());
|
||||
} else {
|
||||
messageService.broadcastPlayerChannelMutedDurationReason(recipient, target.username(),
|
||||
sender.username(), muteEntry.reason(), muteEntry.channel(), muteEntry.expirationEpoch());
|
||||
}
|
||||
} else {
|
||||
if (muteEntry.expirationEpoch() == -1) {
|
||||
messageService.broadcastPlayerMutedPermanentlyReason(recipient, target.username(),
|
||||
sender.username(), muteEntry.reason());
|
||||
} else {
|
||||
messageService.broadcastPlayerMutedDurationReason(recipient, sender.username(),
|
||||
muteEntry.reason(), target.username(), muteEntry.expirationEpoch());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (muteEntry.channel() != null) {
|
||||
if (muteEntry.expirationEpoch() == -1) {
|
||||
messageService.broadcastPlayerChannelMutedPermanently(recipient, target.username(),
|
||||
sender.username(), muteEntry.channel());
|
||||
} else {
|
||||
messageService.broadcastPlayerChannelMutedDuration(recipient, target.username(),
|
||||
sender.username(), muteEntry.channel(), muteEntry.expirationEpoch());
|
||||
}
|
||||
} else {
|
||||
if (muteEntry.expirationEpoch() == -1) {
|
||||
messageService.broadcastPlayerMutedPermanently(recipient, sender.username(),
|
||||
target.username());
|
||||
} else {
|
||||
messageService.broadcastPlayerMutedDuration(recipient, sender.username(),
|
||||
target.username(), muteEntry.expirationEpoch());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+8
-21
@@ -22,8 +22,6 @@ package net.draycia.carbon.common.command.commands;
|
||||
import cloud.commandframework.CommandManager;
|
||||
import cloud.commandframework.arguments.standard.UUIDArgument;
|
||||
import com.google.inject.Inject;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
import net.draycia.carbon.api.CarbonChat;
|
||||
@@ -32,9 +30,6 @@ import net.draycia.carbon.common.command.Commander;
|
||||
import net.draycia.carbon.common.command.PlayerCommander;
|
||||
import net.draycia.carbon.common.command.argument.CarbonPlayerArgument;
|
||||
import net.draycia.carbon.common.messages.CarbonMessageService;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.ComponentLike;
|
||||
import net.kyori.adventure.text.JoinConfiguration;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
|
||||
@@ -69,31 +64,23 @@ public class MuteInfoCommand {
|
||||
target = sender;
|
||||
}
|
||||
|
||||
if (target.muteEntries().isEmpty()) {
|
||||
if (!target.muted()) {
|
||||
if (sender.equals(target)) {
|
||||
messageService.muteInfoSelfNotMuted(sender);
|
||||
messageService.muteInfoSelfMuted(sender);
|
||||
} else {
|
||||
messageService.muteInfoNotMuted(sender, CarbonPlayer.renderName(target));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
final Component channelList;
|
||||
final List<ComponentLike> channelNames = new ArrayList<>();
|
||||
|
||||
for (final var muteEntry : target.muteEntries()) {
|
||||
if (muteEntry.valid()) {
|
||||
if (muteEntry.channel() != null) {
|
||||
channelNames.add(Component.text(muteEntry.channel().value()));
|
||||
} else {
|
||||
channelNames.add(Component.text("all"));
|
||||
}
|
||||
} else {
|
||||
if (sender.equals(target)) {
|
||||
messageService.muteInfoSelfNotMuted(sender);
|
||||
} else {
|
||||
messageService.muteInfoMuted(sender, CarbonPlayer.renderName(target), target.muted());
|
||||
}
|
||||
}
|
||||
|
||||
channelList = Component.join(JoinConfiguration.separator(Component.text(", ")), channelNames);
|
||||
messageService.muteInfoChannels(sender, CarbonPlayer.renderName(target), channelList);
|
||||
messageService.muteInfoMuted(sender, CarbonPlayer.renderName(target), target.muted());
|
||||
})
|
||||
.build();
|
||||
|
||||
|
||||
+1
-1
@@ -79,7 +79,7 @@ public class NicknameCommand {
|
||||
.senderType(PlayerCommander.class)
|
||||
.handler(handler -> {
|
||||
final CarbonPlayer sender = ((PlayerCommander) handler.getSender()).carbonPlayer();
|
||||
long expirationTime = -1; // TODO: implement timed nicknames
|
||||
long expirationTime = -1;
|
||||
@MonotonicNonNull String durationFormat = null;
|
||||
|
||||
if (handler.flags().contains("reset")) {
|
||||
|
||||
@@ -53,6 +53,11 @@ public class ReplyCommand {
|
||||
.handler(handler -> {
|
||||
final CarbonPlayer sender = ((PlayerCommander) handler.getSender()).carbonPlayer();
|
||||
|
||||
if (sender.muted()) {
|
||||
messageService.muteCannotSpeak(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
final String message = handler.get("message");
|
||||
final @Nullable UUID replyTarget = sender.whisperReplyTarget();
|
||||
|
||||
|
||||
@@ -45,9 +45,7 @@ public class UnmuteCommand {
|
||||
) {
|
||||
final var command = commandManager.commandBuilder("unmute")
|
||||
.argument(carbonPlayerArgument.newInstance(false, "player",
|
||||
CarbonPlayerArgument.NO_SENDER.and((sender, player) -> {
|
||||
return !player.muteEntries().isEmpty();
|
||||
})))
|
||||
CarbonPlayerArgument.NO_SENDER.and((sender, player) -> player.muted())))
|
||||
.flag(commandManager.flagBuilder("uuid")
|
||||
.withAliases("u")
|
||||
.withArgument(UUIDArgument.optional("uuid"))
|
||||
@@ -67,20 +65,17 @@ public class UnmuteCommand {
|
||||
throw new IllegalStateException("No target found to unmute.");
|
||||
}
|
||||
|
||||
messageService.playerAlertUnmuted(target);
|
||||
messageService.broadcastPlayerUnmuted(sender, target.username());
|
||||
messageService.unmuteAlertRecipient(target);
|
||||
|
||||
for (final var player : carbonChat.server().players()) {
|
||||
if (player.equals(sender) || player.equals(target)) {
|
||||
if (!player.equals(sender) && !player.hasPermission("carbon.mute.notify")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!player.hasPermission("carbon.mute.notify")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
messageService.broadcastPlayerUnmuted(player, target.username());
|
||||
messageService.unmuteAlertPlayers(player, CarbonPlayer.renderName(target));
|
||||
}
|
||||
|
||||
target.muted(false);
|
||||
})
|
||||
.build();
|
||||
|
||||
|
||||
@@ -46,6 +46,11 @@ public class WhisperCommand {
|
||||
.handler(handler -> {
|
||||
final CarbonPlayer sender = ((PlayerCommander) handler.getSender()).carbonPlayer();
|
||||
|
||||
if (sender.muted()) {
|
||||
messageService.muteCannotSpeak(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
final String message = handler.get("message");
|
||||
final CarbonPlayer recipient = handler.get("recipient");
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ public class MuteHandler {
|
||||
this.messageService = messageService;
|
||||
|
||||
carbonChat.eventHandler().subscribe(CarbonChatEvent.class, 100, false, event -> {
|
||||
if (!event.sender().muted(event.chatChannel())) {
|
||||
if (!event.sender().muted()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,6 @@ import net.draycia.carbon.api.util.SourcedAudience;
|
||||
import net.draycia.carbon.common.util.ChatType;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.audience.MessageType;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.moonshine.annotation.Message;
|
||||
import net.kyori.moonshine.annotation.Placeholder;
|
||||
@@ -75,12 +74,6 @@ public interface CarbonMessageService {
|
||||
final @Placeholder("sender_display_name") Component senderDisplayName
|
||||
);
|
||||
|
||||
@Message("reply.target.offline")
|
||||
void replyTargetOffline(
|
||||
final Audience audience,
|
||||
final @Placeholder("sender_display_name") Component senderDisplayName
|
||||
);
|
||||
|
||||
@Message("reply.target.self")
|
||||
void whisperSelfError(
|
||||
final Audience audience,
|
||||
@@ -93,12 +86,6 @@ public interface CarbonMessageService {
|
||||
final @Placeholder("sender_display_name") Component senderDisplayName
|
||||
);
|
||||
|
||||
@Message("continue.target.offline")
|
||||
void whisperTargetOffline(
|
||||
final Audience audience,
|
||||
final @Placeholder("sender_display_name") Component senderDisplayName
|
||||
);
|
||||
|
||||
@Message("nickname.set")
|
||||
void nicknameSet(
|
||||
final Audience audience,
|
||||
@@ -187,90 +174,9 @@ public interface CarbonMessageService {
|
||||
final @Placeholder String target
|
||||
);
|
||||
|
||||
// pls stop
|
||||
@Message("mute.notify.permanent.reason.channel")
|
||||
void broadcastPlayerChannelMutedPermanentlyReason(
|
||||
final Audience audience,
|
||||
final @Placeholder String sender,
|
||||
final @Placeholder String target,
|
||||
final @Placeholder String reason,
|
||||
final @Placeholder Key channel
|
||||
);
|
||||
|
||||
@Message("mute.notify.temporary.reason.channel")
|
||||
void broadcastPlayerChannelMutedDurationReason(
|
||||
final Audience audience,
|
||||
final @Placeholder String sender,
|
||||
final @Placeholder String target,
|
||||
final @Placeholder String reason,
|
||||
final @Placeholder Key channel,
|
||||
final @Placeholder long duration
|
||||
);
|
||||
|
||||
@Message("mute.notify.permanent.reason")
|
||||
void broadcastPlayerMutedPermanentlyReason(
|
||||
final Audience audience,
|
||||
final @Placeholder String sender,
|
||||
final @Placeholder String target,
|
||||
final @Placeholder String reason
|
||||
);
|
||||
|
||||
@Message("mute.notify.temporary.reason")
|
||||
void broadcastPlayerMutedDurationReason(
|
||||
final Audience audience,
|
||||
final @Placeholder String sender,
|
||||
final @Placeholder String target,
|
||||
final @Placeholder String reason,
|
||||
final @Placeholder long duration
|
||||
);
|
||||
|
||||
@Message("mute.notify.permanent.channel")
|
||||
void broadcastPlayerChannelMutedPermanently(
|
||||
final Audience audience,
|
||||
final @Placeholder String sender,
|
||||
final @Placeholder String target,
|
||||
final @Placeholder Key channel
|
||||
);
|
||||
|
||||
@Message("mute.notify.temporary.channel")
|
||||
void broadcastPlayerChannelMutedDuration(
|
||||
final Audience audience,
|
||||
final @Placeholder String sender,
|
||||
final @Placeholder String target,
|
||||
final @Placeholder Key channel,
|
||||
final @Placeholder long duration
|
||||
);
|
||||
|
||||
@Message("mute.notify.permanent")
|
||||
void broadcastPlayerMutedPermanently(
|
||||
final Audience audience,
|
||||
final @Placeholder String sender,
|
||||
final @Placeholder String target
|
||||
);
|
||||
|
||||
@Message("mute.notify.temporary")
|
||||
void broadcastPlayerMutedDuration(
|
||||
final Audience audience,
|
||||
final @Placeholder String sender,
|
||||
final @Placeholder String target,
|
||||
final @Placeholder long duration
|
||||
);
|
||||
|
||||
@Message("mute.exempt")
|
||||
void muteExempt(final Audience audience);
|
||||
|
||||
@Message("mute.notify.player.muted")
|
||||
void playerAlertMuted(final Audience audience);
|
||||
|
||||
@Message("mute.notify.player.unmuted")
|
||||
void playerAlertUnmuted(final Audience audience);
|
||||
|
||||
@Message("mute.notify.unmuted")
|
||||
void broadcastPlayerUnmuted(
|
||||
final Audience audience,
|
||||
final @Placeholder String target
|
||||
);
|
||||
|
||||
@Message("error.command.no_permission")
|
||||
void errorCommandNoPermission(final Audience audience);
|
||||
|
||||
@@ -314,20 +220,38 @@ public interface CarbonMessageService {
|
||||
@Message("config.reload.failed")
|
||||
void configReloadFailed(final Audience audience);
|
||||
|
||||
@Message("muteinfo.selfnotmuted")
|
||||
@Message("muteinfo.self.muted")
|
||||
void muteInfoSelfMuted(final Audience audience);
|
||||
|
||||
@Message("muteinfo.self.not_muted")
|
||||
void muteInfoSelfNotMuted(final Audience audience);
|
||||
|
||||
@Message("muteinfo.notmuted")
|
||||
@Message("muteinfo.not_muted")
|
||||
void muteInfoNotMuted(
|
||||
final Audience audience,
|
||||
final @Placeholder Component target
|
||||
);
|
||||
|
||||
@Message("muteinfo.info")
|
||||
void muteInfoChannels(
|
||||
@Message("muteinfo.muted")
|
||||
void muteInfoMuted(
|
||||
final Audience audience,
|
||||
final @Placeholder Component target,
|
||||
final @Placeholder Component channels
|
||||
final @Placeholder boolean muted
|
||||
);
|
||||
|
||||
@Message("unmute.alert.target")
|
||||
void unmuteAlertRecipient(final Audience audience);
|
||||
|
||||
@Message("unmute.alert.players")
|
||||
void unmuteAlertPlayers(final Audience audience, final @Placeholder Component target);
|
||||
|
||||
@Message("mute.alert.target")
|
||||
void muteAlertRecipient(final Audience audience);
|
||||
|
||||
@Message("mute.alert.players")
|
||||
void muteAlertPlayers(final Audience audience, final @Placeholder Component target);
|
||||
|
||||
@Message("mute.cannot_speak")
|
||||
void muteCannotSpeak(final Audience audience);
|
||||
|
||||
}
|
||||
@@ -20,14 +20,12 @@
|
||||
package net.draycia.carbon.common.users;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.UUID;
|
||||
import net.draycia.carbon.api.CarbonChatProvider;
|
||||
import net.draycia.carbon.api.channels.ChatChannel;
|
||||
import net.draycia.carbon.api.users.CarbonPlayer;
|
||||
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.audience.ForwardingAudience;
|
||||
@@ -43,7 +41,9 @@ import org.jetbrains.annotations.NotNull;
|
||||
@DefaultQualifier(NonNull.class)
|
||||
public class CarbonPlayerCommon implements CarbonPlayer, ForwardingAudience.Single {
|
||||
|
||||
protected boolean muted = false;
|
||||
protected boolean deafened = false;
|
||||
|
||||
protected @Nullable Key selectedChannel = null;
|
||||
|
||||
// All players have these
|
||||
@@ -63,7 +63,6 @@ public class CarbonPlayerCommon implements CarbonPlayer, ForwardingAudience.Sing
|
||||
protected boolean spying = false;
|
||||
|
||||
// Punishments
|
||||
protected List<MuteEntry> muteEntries = new ArrayList<>();
|
||||
protected List<UUID> ignoredPlayers = new ArrayList<>();
|
||||
|
||||
public CarbonPlayerCommon(
|
||||
@@ -137,50 +136,22 @@ public class CarbonPlayerCommon implements CarbonPlayer, ForwardingAudience.Sing
|
||||
|
||||
@Override
|
||||
public String primaryGroup() {
|
||||
return "default"; // TODO: implement
|
||||
return "default";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> groups() {
|
||||
return List.of("default"); // TODO: implement
|
||||
return List.of("default");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MuteEntry> muteEntries() {
|
||||
return Collections.unmodifiableList(this.muteEntries);
|
||||
public boolean muted() {
|
||||
return this.muted;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean muted(final ChatChannel chatChannel) {
|
||||
for (final var muteEntry : this.muteEntries) {
|
||||
if (!muteEntry.valid()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (muteEntry.channel() == null || chatChannel.key().equals(muteEntry.channel())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable MuteEntry addMuteEntry(
|
||||
final @Nullable ChatChannel chatChannel,
|
||||
final boolean muted,
|
||||
final @Nullable UUID cause,
|
||||
final long duration,
|
||||
final @Nullable String reason
|
||||
) {
|
||||
if (muted) {
|
||||
final var muteEntry = new MuteEntry(System.currentTimeMillis(), cause, duration,
|
||||
reason, chatChannel != null ? chatChannel.key() : null, UUID.randomUUID());
|
||||
this.muteEntries.add(muteEntry);
|
||||
return muteEntry;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
public void muted(final boolean muted) {
|
||||
this.muted = muted;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -26,7 +26,6 @@ import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
import net.draycia.carbon.api.channels.ChatChannel;
|
||||
import net.draycia.carbon.api.users.CarbonPlayer;
|
||||
import net.draycia.carbon.api.users.punishments.MuteEntry;
|
||||
import net.draycia.carbon.api.util.InventorySlot;
|
||||
import net.kyori.adventure.identity.Identity;
|
||||
import net.kyori.adventure.text.Component;
|
||||
@@ -154,24 +153,13 @@ public abstract class WrappedCarbonPlayer implements CarbonPlayer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MuteEntry> muteEntries() {
|
||||
return this.carbonPlayerCommon().muteEntries();
|
||||
public boolean muted() {
|
||||
return this.carbonPlayerCommon().muted();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean muted(final ChatChannel chatChannel) {
|
||||
return this.carbonPlayerCommon().muted(chatChannel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable MuteEntry addMuteEntry(
|
||||
final @Nullable ChatChannel chatChannel,
|
||||
final boolean muted,
|
||||
final @Nullable UUID cause,
|
||||
final long duration,
|
||||
final @Nullable String reason
|
||||
) {
|
||||
return this.carbonPlayerCommon().addMuteEntry(chatChannel, muted, cause, duration, reason);
|
||||
public void muted(final boolean muted) {
|
||||
this.carbonPlayerCommon().muted(muted);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -4,10 +4,8 @@ channel.change=<green>You are now messaging </green><channel><green> chat!</gree
|
||||
whisper.to=<gold>[<green>You</green>] -> [<green><recipient_display_name></green>] <message>
|
||||
whisper.from=<gold>[<green><sender_display_name></green>] -> [<green>You</green>] <message>
|
||||
reply.target.missing=<red>You have no-one to reply to.
|
||||
reply.target.offline=<red>That person is offline.
|
||||
reply.target.self=<red>You cannot whisper to yourself.
|
||||
continue.target.missing=<red>You have no one to whisper.
|
||||
continue.target.offline=<red>That person is offline.
|
||||
nickname.set=<green>Your nickname has been set to </green><nickname><green>.</green>
|
||||
nickname.set.others=<green>You set </green><target><green>'s nickname to </green><nickname><green>.</green>
|
||||
nickname.show.others=<target><green>'s nickname is </green><nickname><green>.</green>
|
||||
@@ -18,18 +16,7 @@ nickname.show.temporary=<green>Your nickname is </green><nickname><green> for </
|
||||
nickname.show.unset=<red>You do not have a nickname set.
|
||||
nickname.set.temporary=<green>Your nickname has been set to </green><nickname><green> for </green><gold><duration></gold><green>.</green>
|
||||
nickname.set.others.temporary=<green>You set </green><target><green>'s nickname to </green><nickname><green> for </green><gold><duration></gold><green>.</green>
|
||||
mute.notify.permanent.reason.channel=<gold><sender> <red>has muted <gold><target> <red>in channel <green><channel> <red>with reason <gold>[<white><reason><gold>]<red>.
|
||||
mute.notify.temporary.reason.channel=<gold><sender> <red>has muted <gold><target> <red>in channel <green><channel> for <yellow><duration> <red>with reason <gold>[<white><reason><gold>]<red>.
|
||||
mute.notify.permanent.reason=<gold><sender> <red>has muted <gold><target> <red>with reason <gold>[<white><reason><gold>]<red>.
|
||||
mute.notify.temporary.reason=<gold><sender> <red>has muted <gold><target> <red>for <yellow><duration> <red>with reason <gold>[<white><reason><gold>]<red>.
|
||||
mute.notify.permanent.channel=<gold><sender> <red>has muted <gold><target> <red>in channel <green><channel><red>.
|
||||
mute.notify.temporary.channel=<gold><sender> <red>has muted <gold><target> <red>in channel <green><channel> <red>for <yellow><duration><red>.
|
||||
mute.notify.permanent=<gold><sender> <red>has muted <gold><target><red>.
|
||||
mute.notify.temporary=<gold><sender> <red>has muted <gold><target> <red>for <yellow><duration><red>.
|
||||
mute.exempt=<red>That player is exempt from being muted!
|
||||
mute.notify.player.muted=<#aa0000>You have been muted!
|
||||
mute.notify.player.unmuted=<green>You are no longer muted!
|
||||
mute.notify.unmuted=<gold><target> <green>has been unmuted!
|
||||
error.command.no_permission=<red>I'm sorry, but you do not have permission to perform this command.\nPlease contact the server administrators if you believe that this is in error.
|
||||
error.command.command_execution=<hover:show_text:"<throwable_message>\n<stacktrace>\n<gray><italic> Click to copy"><click:copy_to_clipboard:<stacktrace>><red>An internal error occurred while attempting to perform this command.
|
||||
error.command.argument_parsing=<red>Invalid command argument: <gray><throwable_message>
|
||||
@@ -60,6 +47,7 @@ whisper.ignoring_target=<red>You are ignoring <target>
|
||||
whisper.ignored_by_target=<red><target> <red>is ignoring you
|
||||
config.reload.success=<green>Config reloaded successfully
|
||||
config.reload.failed=<red>Config failed to reload
|
||||
muteinfo.selfnotmuted=<red>You are not muted
|
||||
muteinfo.notmuted=<red><target> <gold>is not muted
|
||||
muteinfo.info=<red><target> <red>is muted in:
|
||||
muteinfo.self.not_muted=<green>You are not muted
|
||||
muteinfo.self.muted=<red>You are muted
|
||||
muteinfo.not_muted=<red><target> <gold>is not muted
|
||||
muteinfo.muted=<red><target> <red>is muted
|
||||
+1
-1
@@ -55,7 +55,7 @@ public class FabricPlayerDeathListener implements PlayerStatusMessageEvents.Mess
|
||||
|
||||
final CarbonPlayer player = result.player();
|
||||
|
||||
if (!player.muteEntries().isEmpty()) {
|
||||
if (player.muted()) {
|
||||
event.disableMessage();
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -52,7 +52,7 @@ public class FabricPlayerJoinListener implements PlayerStatusMessageEvents.Messa
|
||||
}
|
||||
|
||||
// Don't show join messages when muted
|
||||
if (this.configFactory.primaryConfig().hideMutedJoinLeaveQuit() && !player.muteEntries().isEmpty()) {
|
||||
if (this.configFactory.primaryConfig().hideMutedJoinLeaveQuit() && player.muted()) {
|
||||
event.disableMessage();
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -62,7 +62,7 @@ public class FabricPlayerLeaveListener implements PlayerStatusMessageEvents.Mess
|
||||
final CarbonPlayer player = result.player();
|
||||
|
||||
if (this.configFactory.primaryConfig().hideMutedJoinLeaveQuit()) {
|
||||
if (!player.muteEntries().isEmpty()) {
|
||||
if (player.muted()) {
|
||||
event.disableMessage();
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -58,7 +58,7 @@ public class SpongePlayerDeathListener {
|
||||
|
||||
final CarbonPlayer carbonPlayer = result.player();
|
||||
|
||||
if (!carbonPlayer.muteEntries().isEmpty()) {
|
||||
if (carbonPlayer.muted()) {
|
||||
event.setMessageCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -63,7 +63,7 @@ public class SpongePlayerJoinListener {
|
||||
}
|
||||
|
||||
// Don't show join messages when muted
|
||||
if (this.configFactory.primaryConfig().hideMutedJoinLeaveQuit() && !player.muteEntries().isEmpty()) {
|
||||
if (this.configFactory.primaryConfig().hideMutedJoinLeaveQuit() && player.muted()) {
|
||||
event.setMessageCancelled(true);
|
||||
}
|
||||
}
|
||||
@@ -80,7 +80,7 @@ public class SpongePlayerJoinListener {
|
||||
final CarbonPlayer player = result.player();
|
||||
|
||||
if (this.configFactory.primaryConfig().hideMutedJoinLeaveQuit()) {
|
||||
if (!player.muteEntries().isEmpty()) {
|
||||
if (player.muted()) {
|
||||
event.setAudience(Audience.empty());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user