vote_mute #2

Merged
stijn merged 19 commits from vote_mute into main 2025-01-22 20:45:21 +00:00
4 changed files with 21 additions and 9 deletions
Showing only changes of commit 782c7df4ef - Show all commits

View File

@ -110,10 +110,10 @@ public class VoteToMute {
}
boolean countLowerRanks = false;
long count = getTotalEligiblePlayers(server, false);
if (count < 10) {
if (count < 6) {
countLowerRanks = true;
count = getTotalEligiblePlayers(server, true);
if (count < 10) {
if (count < 6) {
commandContext.getSource().sendMessage(Utility.parseMiniMessage("<red>Not enough eligible players online to vote.</red>"));
return 1;
}

View File

@ -116,7 +116,7 @@ public class VoteToMuteHelper {
return 1;
});
LiteralArgumentBuilder<CommandSource> enterPageNode = LiteralArgumentBuilder
LiteralArgumentBuilder<CommandSource> enterMessagesNode = LiteralArgumentBuilder
.<CommandSource>literal("messages")
.requires(commandSource -> commandSource.hasPermission("chat.vote-to-mute"))
.then(RequiredArgumentBuilder.<CommandSource, String>argument("list of messages", StringArgumentType.greedyString())
@ -199,8 +199,16 @@ public class VoteToMuteHelper {
String vote = commandContext.getArgument("yesNo", String.class);
switch (vote.toLowerCase()) {
case "yes" -> activeVoteToMute.vote(source.getUniqueId(), true);
case "no" -> activeVoteToMute.vote(source.getUniqueId(), false);
case "yes" -> {
activeVoteToMute.vote(source.getUniqueId(), true);
commandContext.getSource().sendMessage(Utility.parseMiniMessage(
"<green>You voted to mute. Thanks for voting, staff will be online soon to review!</green>"));
}
case "no" -> {
activeVoteToMute.vote(source.getUniqueId(), false);
commandContext.getSource().sendMessage(Utility.parseMiniMessage(
"<green>You voted <red>not</red> to mute. Thanks for voting, staff will be online soon to review!</green>"));
}
default -> commandContext.getSource().sendMessage(Utility.parseMiniMessage(
"<red><vote> is not a valid vote option</red>", Placeholder.parsed("vote", vote)));
}
@ -219,7 +227,7 @@ public class VoteToMuteHelper {
.requires(commandSource -> commandSource instanceof Player)
.then(voteNode)
.then(pageNode)
.then(enterPageNode)
.then(enterMessagesNode)
.executes(context -> {
sendHelpMessage(context.getSource());
return 1;

View File

@ -35,6 +35,7 @@ public class ActiveVoteToMute {
private final RegisteredServer server;
private final ProxyServer proxyServer;
private final Component chatLogs;
private boolean endedVote = false;
public static Optional<ActiveVoteToMute> getInstance(String username) {
if (!instances.containsKey(username))
@ -91,6 +92,8 @@ public class ActiveVoteToMute {
}
private void endVote() {
if (endedVote)
return;
instances.remove(votedPlayer.getUsername());
if (votePassed()) {
mutePlayer();
@ -117,6 +120,7 @@ public class ActiveVoteToMute {
if (!votePassed()) {
return;
}
endedVote = true;
instances.remove(votedPlayer.getUsername());
mutePlayer();
} else {
@ -206,7 +210,7 @@ public class ActiveVoteToMute {
private Component getVoteStartMessage() {
return Utility.parseMiniMessage(
String.format("""
<prefix> <gold>[VoteMute]</gold> <green>A vote to mute <player> for one hour has been started, please read the logs below before voting.</green>
<prefix> <green>A vote to mute <player> for one hour has been started, please read the logs below before voting.</green>
<logs>
<prefix> Click: <click:run_command:'/votetomutehelper vote %s yes'><red>Mute</red></click> --- <click:run_command:'/votetomutehelper vote %s no'><yellow>Don't mute</yellow></click>""",
votedPlayer.getUsername(), votedPlayer.getUsername()),

View File

@ -52,8 +52,8 @@ public class VoteToMuteStarter {
parseChatLogs(chatLogs);
commandSource.sendMessage(Utility.parseMiniMessage(
"<prefix> <green>Please select up to 10 messages other players should see to decide their vote, seperated by comma's. " +
"Example: <gold>/votetomutehelper messages 1, 2, 5, 8</gold></green>"));
showPage(0);
"Example: <gold>/votetomutehelper messages 1, 2, 5, 8</gold></green>", Placeholder.component("prefix", prefix)));
showPage(1);
});
}