Fix message validation and chat log order

Corrected conditional logic in VoteToMuteHelper to validate messages properly and adjusted sorting of chat logs in VoteToMuteStarter to display in reverse chronological order. The update now accurately verifies the existence of selected messages and presents recent logs first for more user-friendly navigation.
This commit is contained in:
2024-06-04 21:18:57 +02:00
parent 8393d12c6d
commit a908e32d0b
2 changed files with 2 additions and 2 deletions
@@ -150,7 +150,7 @@ public class VoteToMuteHelper {
} }
int highestLogEntry = max.get(); int highestLogEntry = max.get();
if (voteToMuteStarter.getTotalLogEntries() > highestLogEntry) { if (voteToMuteStarter.getTotalLogEntries() < highestLogEntry) {
commandContext.getSource().sendMessage(Utility.parseMiniMessage("<red>Some of your selected messages do not exist.</red>")); commandContext.getSource().sendMessage(Utility.parseMiniMessage("<red>Some of your selected messages do not exist.</red>"));
return 1; return 1;
} }
@@ -60,7 +60,7 @@ public class VoteToMuteStarter {
private void parseChatLogs(List<ChatLog> chatLogs) { private void parseChatLogs(List<ChatLog> chatLogs) {
TagResolver.Single playerTag = Placeholder.parsed("player", votedPlayer.getUsername()); TagResolver.Single playerTag = Placeholder.parsed("player", votedPlayer.getUsername());
TagResolver.Single prefixTag = Placeholder.component("prefix", prefix); TagResolver.Single prefixTag = Placeholder.component("prefix", prefix);
chatLogs.sort(Comparator.comparing(ChatLog::getTimestamp)); chatLogs.sort(Comparator.comparing(ChatLog::getTimestamp).reversed());
parsedChatLogs = IntStream.range(0, chatLogs.size()) parsedChatLogs = IntStream.range(0, chatLogs.size())
.mapToObj(i -> Utility.parseMiniMessage( .mapToObj(i -> Utility.parseMiniMessage(
"<number>. <prefix> <player>: <message>", "<number>. <prefix> <player>: <message>",