From a876a9f77b81254ec36e9b3ebadbdf62a059b78b Mon Sep 17 00:00:00 2001 From: Teriuihi Date: Sun, 5 May 2024 00:11:56 +0200 Subject: [PATCH] Update vote validation and argument naming Updated the method "votePassed" in "ActiveVoteToMute" to consider a scenario where no votes have been made for muting. Also, corrected the argument name from "yesno" to "yesNo" in "VoteToMuteHelper" to match with its name in the command constructor --- .../java/com/alttd/velocitychat/commands/VoteToMuteHelper.java | 2 +- .../velocitychat/commands/vote_to_mute/ActiveVoteToMute.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/velocity/src/main/java/com/alttd/velocitychat/commands/VoteToMuteHelper.java b/velocity/src/main/java/com/alttd/velocitychat/commands/VoteToMuteHelper.java index b2c6666..34effdc 100644 --- a/velocity/src/main/java/com/alttd/velocitychat/commands/VoteToMuteHelper.java +++ b/velocity/src/main/java/com/alttd/velocitychat/commands/VoteToMuteHelper.java @@ -197,7 +197,7 @@ public class VoteToMuteHelper { } } - String vote = commandContext.getArgument("yesno", String.class); + String vote = commandContext.getArgument("yesNo", String.class); switch (vote.toLowerCase()) { case "yes" -> activeVoteToMute.vote(source.getUniqueId(), true); case "no" -> activeVoteToMute.vote(source.getUniqueId(), false); diff --git a/velocity/src/main/java/com/alttd/velocitychat/commands/vote_to_mute/ActiveVoteToMute.java b/velocity/src/main/java/com/alttd/velocitychat/commands/vote_to_mute/ActiveVoteToMute.java index cb427bc..4448a50 100644 --- a/velocity/src/main/java/com/alttd/velocitychat/commands/vote_to_mute/ActiveVoteToMute.java +++ b/velocity/src/main/java/com/alttd/velocitychat/commands/vote_to_mute/ActiveVoteToMute.java @@ -127,7 +127,7 @@ public class ActiveVoteToMute { public boolean votePassed() { double totalVotes = (votedFor.size() + votedAgainst.size()); - if (totalVotes == 0) { + if (totalVotes == 0 || votedFor.isEmpty()) { return false; } if (totalVotes / totalEligibleVoters < 0.6) {