Add mute vote results sent to Discord and staff presence check
Enhanced the vote-to-mute feature by adding a function that sends the mute vote results to a general channel on Discord. A 'staff presence' check has also been added which prevents the mute vote from being initiated if a staff member is online, instead, it prompts users to directly contact a staff member for help.
This commit is contained in:
parent
c057c69653
commit
d6135f2456
|
|
@ -104,6 +104,10 @@ public class VoteToMute {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
RegisteredServer server = currentServer.get().getServer();
|
RegisteredServer server = currentServer.get().getServer();
|
||||||
|
if (currentServer.get().getServer().getPlayersConnected().stream().anyMatch(onlinePlayer -> onlinePlayer.hasPermission("chat.staff"))) {
|
||||||
|
commandContext.getSource().sendMessage(Utility.parseMiniMessage("<red>There is a staff member online, so vote to mute can not be used. Please contact a staff member for help instead.</red>"));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
boolean countLowerRanks = false;
|
boolean countLowerRanks = false;
|
||||||
long count = getTotalEligiblePlayers(server, false);
|
long count = getTotalEligiblePlayers(server, false);
|
||||||
if (count < 10) {
|
if (count < 10) {
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,19 @@
|
||||||
package com.alttd.velocitychat.commands.vote_to_mute;
|
package com.alttd.velocitychat.commands.vote_to_mute;
|
||||||
|
|
||||||
|
import com.alttd.chat.config.Config;
|
||||||
import com.alttd.chat.util.Utility;
|
import com.alttd.chat.util.Utility;
|
||||||
|
import com.alttd.proxydiscordlink.DiscordLink;
|
||||||
|
import com.alttd.proxydiscordlink.lib.net.dv8tion.jda.api.EmbedBuilder;
|
||||||
import com.velocitypowered.api.proxy.Player;
|
import com.velocitypowered.api.proxy.Player;
|
||||||
import com.velocitypowered.api.proxy.ProxyServer;
|
import com.velocitypowered.api.proxy.ProxyServer;
|
||||||
import com.velocitypowered.api.proxy.ServerConnection;
|
import com.velocitypowered.api.proxy.ServerConnection;
|
||||||
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
|
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
|
@ -141,6 +146,22 @@ public class ActiveVoteToMute {
|
||||||
.forEach(player -> player.sendMessage(message));
|
.forEach(player -> player.sendMessage(message));
|
||||||
proxyServer.getCommandManager().executeAsync(proxyServer.getConsoleCommandSource(),
|
proxyServer.getCommandManager().executeAsync(proxyServer.getConsoleCommandSource(),
|
||||||
String.format("tempmute %s 1h Muted by the community - under review.", votedPlayer.getUsername()));
|
String.format("tempmute %s 1h Muted by the community - under review.", votedPlayer.getUsername()));
|
||||||
|
|
||||||
|
|
||||||
|
EmbedBuilder embedBuilder = new EmbedBuilder();
|
||||||
|
embedBuilder.setAuthor(votedPlayer.getUsername(), null, "https://crafatar.com/avatars/" + votedPlayer.getUniqueId() + "?overlay");
|
||||||
|
embedBuilder.setTitle("Player muted by vote");
|
||||||
|
embedBuilder.setColor(Color.CYAN);
|
||||||
|
String chatLogsString = PlainTextComponentSerializer.plainText().serialize(chatLogs);
|
||||||
|
embedBuilder.addField("Logs",
|
||||||
|
chatLogsString.substring(0, Math.min(chatLogsString.length(), 1024)),
|
||||||
|
false);
|
||||||
|
embedBuilder.addField("Server",
|
||||||
|
server.getServerInfo().getName().substring(0, 1).toUpperCase() + server.getServerInfo().getName().substring(1),
|
||||||
|
false);
|
||||||
|
|
||||||
|
long id = Config.serverChannelId.get("general");
|
||||||
|
DiscordLink.getPlugin().getBot().sendEmbedToDiscord(id, embedBuilder, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addEligibleVoter(Player player) {
|
public void addEligibleVoter(Player player) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user