vote_mute #2
|
|
@ -110,10 +110,10 @@ public class VoteToMute {
|
||||||
}
|
}
|
||||||
boolean countLowerRanks = false;
|
boolean countLowerRanks = false;
|
||||||
long count = getTotalEligiblePlayers(server, false);
|
long count = getTotalEligiblePlayers(server, false);
|
||||||
if (count < 10) {
|
if (count < 6) {
|
||||||
countLowerRanks = true;
|
countLowerRanks = true;
|
||||||
count = getTotalEligiblePlayers(server, 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>"));
|
commandContext.getSource().sendMessage(Utility.parseMiniMessage("<red>Not enough eligible players online to vote.</red>"));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -116,7 +116,7 @@ public class VoteToMuteHelper {
|
||||||
return 1;
|
return 1;
|
||||||
});
|
});
|
||||||
|
|
||||||
LiteralArgumentBuilder<CommandSource> enterPageNode = LiteralArgumentBuilder
|
LiteralArgumentBuilder<CommandSource> enterMessagesNode = LiteralArgumentBuilder
|
||||||
.<CommandSource>literal("messages")
|
.<CommandSource>literal("messages")
|
||||||
.requires(commandSource -> commandSource.hasPermission("chat.vote-to-mute"))
|
.requires(commandSource -> commandSource.hasPermission("chat.vote-to-mute"))
|
||||||
.then(RequiredArgumentBuilder.<CommandSource, String>argument("list of messages", StringArgumentType.greedyString())
|
.then(RequiredArgumentBuilder.<CommandSource, String>argument("list of messages", StringArgumentType.greedyString())
|
||||||
|
|
@ -199,8 +199,16 @@ public class VoteToMuteHelper {
|
||||||
|
|
||||||
String vote = commandContext.getArgument("yesNo", String.class);
|
String vote = commandContext.getArgument("yesNo", String.class);
|
||||||
switch (vote.toLowerCase()) {
|
switch (vote.toLowerCase()) {
|
||||||
case "yes" -> activeVoteToMute.vote(source.getUniqueId(), true);
|
case "yes" -> {
|
||||||
case "no" -> activeVoteToMute.vote(source.getUniqueId(), false);
|
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(
|
default -> commandContext.getSource().sendMessage(Utility.parseMiniMessage(
|
||||||
"<red><vote> is not a valid vote option</red>", Placeholder.parsed("vote", vote)));
|
"<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)
|
.requires(commandSource -> commandSource instanceof Player)
|
||||||
.then(voteNode)
|
.then(voteNode)
|
||||||
.then(pageNode)
|
.then(pageNode)
|
||||||
.then(enterPageNode)
|
.then(enterMessagesNode)
|
||||||
.executes(context -> {
|
.executes(context -> {
|
||||||
sendHelpMessage(context.getSource());
|
sendHelpMessage(context.getSource());
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@ public class ActiveVoteToMute {
|
||||||
private final RegisteredServer server;
|
private final RegisteredServer server;
|
||||||
private final ProxyServer proxyServer;
|
private final ProxyServer proxyServer;
|
||||||
private final Component chatLogs;
|
private final Component chatLogs;
|
||||||
|
private boolean endedVote = false;
|
||||||
|
|
||||||
public static Optional<ActiveVoteToMute> getInstance(String username) {
|
public static Optional<ActiveVoteToMute> getInstance(String username) {
|
||||||
if (!instances.containsKey(username))
|
if (!instances.containsKey(username))
|
||||||
|
|
@ -91,6 +92,8 @@ public class ActiveVoteToMute {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void endVote() {
|
private void endVote() {
|
||||||
|
if (endedVote)
|
||||||
|
return;
|
||||||
instances.remove(votedPlayer.getUsername());
|
instances.remove(votedPlayer.getUsername());
|
||||||
if (votePassed()) {
|
if (votePassed()) {
|
||||||
mutePlayer();
|
mutePlayer();
|
||||||
|
|
@ -117,6 +120,7 @@ public class ActiveVoteToMute {
|
||||||
if (!votePassed()) {
|
if (!votePassed()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
endedVote = true;
|
||||||
instances.remove(votedPlayer.getUsername());
|
instances.remove(votedPlayer.getUsername());
|
||||||
mutePlayer();
|
mutePlayer();
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -206,7 +210,7 @@ public class ActiveVoteToMute {
|
||||||
private Component getVoteStartMessage() {
|
private Component getVoteStartMessage() {
|
||||||
return Utility.parseMiniMessage(
|
return Utility.parseMiniMessage(
|
||||||
String.format("""
|
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>
|
<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>""",
|
<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()),
|
votedPlayer.getUsername(), votedPlayer.getUsername()),
|
||||||
|
|
|
||||||
|
|
@ -52,8 +52,8 @@ public class VoteToMuteStarter {
|
||||||
parseChatLogs(chatLogs);
|
parseChatLogs(chatLogs);
|
||||||
commandSource.sendMessage(Utility.parseMiniMessage(
|
commandSource.sendMessage(Utility.parseMiniMessage(
|
||||||
"<prefix> <green>Please select up to 10 messages other players should see to decide their vote, seperated by comma's. " +
|
"<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>"));
|
"Example: <gold>/votetomutehelper messages 1, 2, 5, 8</gold></green>", Placeholder.component("prefix", prefix)));
|
||||||
showPage(0);
|
showPage(1);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user