From e533e3c68bc5d9d019344baf394f03481c9df005 Mon Sep 17 00:00:00 2001 From: "Vyacheslav N. Boyko" Date: Wed, 11 Apr 2018 13:25:16 +0300 Subject: [PATCH] improved. if top all size > 10 - sending in private --- .../jircbot/listeners/StatisticsListener.java | 36 ++++++++++++++----- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/src/main/java/ru/bvn13/jircbot/listeners/StatisticsListener.java b/src/main/java/ru/bvn13/jircbot/listeners/StatisticsListener.java index 1970ef9..9f86f7a 100644 --- a/src/main/java/ru/bvn13/jircbot/listeners/StatisticsListener.java +++ b/src/main/java/ru/bvn13/jircbot/listeners/StatisticsListener.java @@ -89,11 +89,21 @@ public class StatisticsListener extends ImprovedListenerAdapter { event.respondChannel("Statistics is empty now"); return; } - event.respondChannel("TOP for all over time:"); - for (int i = 0; i < statistics.size(); i++) { - StatisticsDTO stats = statistics.get(i); - event.respondChannel("" + (i + 1) + ". " + stats.getUsername() + " - " + stats.getCount()); + if (statistics.size() > 10) { + event.respondPrivateMessage("TOP for all over time:"); + + for (int i = 0; i < statistics.size(); i++) { + StatisticsDTO stats = statistics.get(i); + event.respondPrivateMessage("" + (i + 1) + ". " + stats.getUsername() + " - " + stats.getCount()); + } + } else { + event.respondChannel("TOP for all over time:"); + + for (int i = 0; i < statistics.size(); i++) { + StatisticsDTO stats = statistics.get(i); + event.respondChannel("" + (i + 1) + ". " + stats.getUsername() + " - " + stats.getCount()); + } } } else if (commands.length == 3) { @@ -113,11 +123,21 @@ public class StatisticsListener extends ImprovedListenerAdapter { event.respondChannel("Statistics for "+periodInfo.period+" is empty now"); return; } - event.respondChannel("TOP for "+periodInfo.period+":"); - for (int i = 0; i < statistics.size(); i++) { - StatisticsDTO stats = statistics.get(i); - event.respondChannel("" + (i + 1) + ". " + stats.getUsername() + " - " + stats.getCount()); + if (statistics.size() > 10) { + event.respondPrivateMessage("TOP for " + periodInfo.period + ":"); + + for (int i = 0; i < statistics.size(); i++) { + StatisticsDTO stats = statistics.get(i); + event.respondPrivateMessage("" + (i + 1) + ". " + stats.getUsername() + " - " + stats.getCount()); + } + } else { + event.respondChannel("TOP for " + periodInfo.period + ":"); + + for (int i = 0; i < statistics.size(); i++) { + StatisticsDTO stats = statistics.get(i); + event.respondChannel("" + (i + 1) + ". " + stats.getUsername() + " - " + stats.getCount()); + } } } else {