Adeed Utils.plural() method.
This commit is contained in:
parent
85c7fe14fd
commit
d4e4672952
5 changed files with 35 additions and 8 deletions
|
@ -13,8 +13,8 @@ import java.util.Date;
|
||||||
* Annotation Processor</a>
|
* Annotation Processor</a>
|
||||||
*/
|
*/
|
||||||
public final class ReleaseInfo {
|
public final class ReleaseInfo {
|
||||||
private final static String buildmeta = "002";
|
private final static String buildmeta = "004";
|
||||||
private final static Date date = new Date(1467518031071L);
|
private final static Date date = new Date(1467595869139L);
|
||||||
private final static int major = 0;
|
private final static int major = 0;
|
||||||
private final static int minor = 7;
|
private final static int minor = 7;
|
||||||
private final static int patch = 0;
|
private final static int patch = 0;
|
||||||
|
|
|
@ -1120,7 +1120,14 @@ public class Mobibot extends PircBot
|
||||||
{
|
{
|
||||||
for (final String info : INFO_STRS)
|
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;
|
long timeInSeconds = (System.currentTimeMillis() - START_TIME) / 1000L;
|
||||||
|
@ -1134,7 +1141,8 @@ public class Mobibot extends PircBot
|
||||||
final long minutes = timeInSeconds / 60L;
|
final long minutes = timeInSeconds / 60L;
|
||||||
|
|
||||||
send(sender,
|
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() : "") + ']',
|
+ (tell.isEnabled() && isOp(sender) ? ", Messages: " + tell.size() : "") + ']',
|
||||||
isPrivate);
|
isPrivate);
|
||||||
}
|
}
|
||||||
|
|
|
@ -216,7 +216,7 @@ public class Tell
|
||||||
bot.send(sender,
|
bot.send(sender,
|
||||||
bot.helpIndent(bot.getNick() + ": " + TELL_CMD + ' ' + TELL_DEL_KEYWORD + " <id|"
|
bot.helpIndent(bot.getNick() + ": " + TELL_CMD + ' ' + TELL_DEL_KEYWORD + " <id|"
|
||||||
+ TELL_ALL_KEYWORD + '>'));
|
+ TELL_ALL_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, "To view queued and sent messages:");
|
||||||
bot.send(sender, bot.helpIndent(bot.getNick() + ": " + TELL_CMD + ' ' + Commands.VIEW_CMD));
|
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();
|
return messages.size();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -309,6 +309,25 @@ final public class Utils
|
||||||
return false;
|
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.
|
* Makes the given string reverse color.
|
||||||
*
|
*
|
||||||
|
|
|
@ -5,4 +5,4 @@ version.major=0
|
||||||
version.minor=7
|
version.minor=7
|
||||||
version.patch=0
|
version.patch=0
|
||||||
version.prerelease=beta
|
version.prerelease=beta
|
||||||
version.buildmeta=002
|
version.buildmeta=004
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue