Skip to content
This repository has been archived by the owner on Jan 20, 2024. It is now read-only.

Commit

Permalink
Add possibility to disable moderation announcements
Browse files Browse the repository at this point in the history
  • Loading branch information
fxdsu committed Jul 16, 2023
1 parent 416398c commit 73c5aa9
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
15 changes: 11 additions & 4 deletions src/main/java/net/flectone/commands/CommandMute.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;

public class CommandMute extends FTabCompleter {

Expand Down Expand Up @@ -57,7 +57,14 @@ public boolean onCommand(@NotNull CommandSender commandSender, @NotNull Command
.replace("<time>", ObjectUtil.convertTimeToString(time))
.replace("<reason>", reason);

fCommand.sendGlobalMessage(new HashSet<>(Bukkit.getOnlinePlayers()), formatString, false);
boolean announceModeration = Main.config.getBoolean("command.mute.announce");

Set<Player> receivers = announceModeration
? new HashSet<>(Bukkit.getOnlinePlayers())
: Bukkit.getOnlinePlayers().stream()
.filter(player -> player.hasPermission("flectonechat.mute")).collect(Collectors.toSet());

fCommand.sendGlobalMessage(receivers, formatString, false);

if(Main.isHavePlasmoVoice) {
FlectonePlasmoVoice.mute(mutedFPlayer.isMuted(), mutedFPlayer.getRealName(), strings[1], reason);
Expand Down
10 changes: 9 additions & 1 deletion src/main/java/net/flectone/commands/CommandTempban.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

public class CommandTempban extends FTabCompleter {
Expand Down Expand Up @@ -61,7 +62,14 @@ public boolean onCommand(@NotNull CommandSender commandSender, @NotNull Command
.replace("<time>", ObjectUtil.convertTimeToString(time))
.replace("<reason>", reason);

fCommand.sendGlobalMessage(new HashSet<>(Bukkit.getOnlinePlayers()), globalMessage, false);
boolean announceModeration = Main.config.getBoolean("command.tempban.announce");

Set<Player> receivers = announceModeration
? new HashSet<>(Bukkit.getOnlinePlayers())
: Bukkit.getOnlinePlayers().stream()
.filter(player -> player.hasPermission("flectonechat.ban")).collect(Collectors.toSet());

fCommand.sendGlobalMessage(receivers, globalMessage, false);

bannedFPlayer.setTempBanTime(time == -1 ? -1 : time + ObjectUtil.getCurrentTime());
bannedFPlayer.setTempBanReason(reason);
Expand Down
6 changes: 6 additions & 0 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,12 @@ command:
see:
permission: "flectonechat.helpersee"

mute:
announce: true

tempban:
announce: true

cool-down:
enable: false

Expand Down

0 comments on commit 73c5aa9

Please sign in to comment.