From d4e46729525da481a3b046d3792080db77aea51b Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Sun, 3 Jul 2016 18:39:42 -0700 Subject: [PATCH] Adeed Utils.plural() method. --- .../net/thauvin/erik/mobibot/ReleaseInfo.java | 4 ++-- .../net/thauvin/erik/mobibot/Mobibot.java | 12 ++++++++++-- .../java/net/thauvin/erik/mobibot/Tell.java | 6 +++--- .../java/net/thauvin/erik/mobibot/Utils.java | 19 +++++++++++++++++++ version.properties | 2 +- 5 files changed, 35 insertions(+), 8 deletions(-) diff --git a/src/generated/java/net/thauvin/erik/mobibot/ReleaseInfo.java b/src/generated/java/net/thauvin/erik/mobibot/ReleaseInfo.java index 087d0a7..94fd13a 100644 --- a/src/generated/java/net/thauvin/erik/mobibot/ReleaseInfo.java +++ b/src/generated/java/net/thauvin/erik/mobibot/ReleaseInfo.java @@ -13,8 +13,8 @@ import java.util.Date; * Annotation Processor */ public final class ReleaseInfo { - private final static String buildmeta = "002"; - private final static Date date = new Date(1467518031071L); + private final static String buildmeta = "004"; + private final static Date date = new Date(1467595869139L); private final static int major = 0; private final static int minor = 7; private final static int patch = 0; diff --git a/src/main/java/net/thauvin/erik/mobibot/Mobibot.java b/src/main/java/net/thauvin/erik/mobibot/Mobibot.java index b6fa9c2..9986482 100644 --- a/src/main/java/net/thauvin/erik/mobibot/Mobibot.java +++ b/src/main/java/net/thauvin/erik/mobibot/Mobibot.java @@ -1120,7 +1120,14 @@ public class Mobibot extends PircBot { for (final String info : INFO_STRS) { - send(sender, info, isPrivate); + if (info.startsWith("http://")) + { + send(sender, Utils.green(info), isPrivate); + } + else + { + send(sender, info, isPrivate); + } } long timeInSeconds = (System.currentTimeMillis() - START_TIME) / 1000L; @@ -1134,7 +1141,8 @@ public class Mobibot extends PircBot final long minutes = timeInSeconds / 60L; send(sender, - "Uptime: " + days + " day(s) " + hours + " hour(s) " + minutes + " minute(s) [Entries: " + entries.size() + "Uptime: " + days + Utils.plural(days, " day ", " days ") + hours + Utils.plural(hours, " hour ", " hours ") + + minutes + Utils.plural(minutes, " minute ", " minutes ") + "[Entries: " + entries.size() + (tell.isEnabled() && isOp(sender) ? ", Messages: " + tell.size() : "") + ']', isPrivate); } diff --git a/src/main/java/net/thauvin/erik/mobibot/Tell.java b/src/main/java/net/thauvin/erik/mobibot/Tell.java index ea74164..804cefd 100644 --- a/src/main/java/net/thauvin/erik/mobibot/Tell.java +++ b/src/main/java/net/thauvin/erik/mobibot/Tell.java @@ -216,7 +216,7 @@ public class Tell bot.send(sender, bot.helpIndent(bot.getNick() + ": " + TELL_CMD + ' ' + TELL_DEL_KEYWORD + " ')); - bot.send(sender, "Messages are kept for " + Utils.bold(maxDays) + " days."); + bot.send(sender, "Messages are kept for " + Utils.bold(maxDays) + Utils.plural(maxDays, " day.", " days.")); } } } @@ -336,7 +336,7 @@ public class Tell bot.send(sender, "To view queued and sent messages:"); bot.send(sender, bot.helpIndent(bot.getNick() + ": " + TELL_CMD + ' ' + Commands.VIEW_CMD)); - bot.send(sender, "Messages are kept for " + Utils.bold(maxDays) + " days."); + bot.send(sender, "Messages are kept for " + Utils.bold(maxDays) + Utils.plural(maxDays, " day.", " days.")); } /** @@ -425,4 +425,4 @@ public class Tell { return messages.size(); } -} \ No newline at end of file +} diff --git a/src/main/java/net/thauvin/erik/mobibot/Utils.java b/src/main/java/net/thauvin/erik/mobibot/Utils.java index 424fb80..e2e7531 100644 --- a/src/main/java/net/thauvin/erik/mobibot/Utils.java +++ b/src/main/java/net/thauvin/erik/mobibot/Utils.java @@ -309,6 +309,25 @@ final public class Utils return false; } + /** + * Returns the plural form of a word, if count > 1. + * + * @param count The count. + * @param word The word. + * @param plural The plural word. + */ + public static String plural(final long count, final String word, final String plural) + { + if (count > 1) + { + return plural; + } + else + { + return word; + } + } + /** * Makes the given string reverse color. * diff --git a/version.properties b/version.properties index 1e42163..eece5fb 100644 --- a/version.properties +++ b/version.properties @@ -5,4 +5,4 @@ version.major=0 version.minor=7 version.patch=0 version.prerelease=beta -version.buildmeta=002 +version.buildmeta=004