diff options
author | KHobbits <rob@khobbits.co.uk> | 2013-09-10 01:42:11 +0100 |
---|---|---|
committer | KHobbits <rob@khobbits.co.uk> | 2013-09-10 01:42:11 +0100 |
commit | 3963a528b3aa633a056816c12a665bcaa818bf09 (patch) | |
tree | 14b12ec837f5df1b7ae38eff8f55ae0a4271ef59 | |
parent | 7c686b4b58ca7018df21dbd271e3682bd6aa4175 (diff) | |
download | Essentials-3963a528b3aa633a056816c12a665bcaa818bf09.tar Essentials-3963a528b3aa633a056816c12a665bcaa818bf09.tar.gz Essentials-3963a528b3aa633a056816c12a665bcaa818bf09.tar.lz Essentials-3963a528b3aa633a056816c12a665bcaa818bf09.tar.xz Essentials-3963a528b3aa633a056816c12a665bcaa818bf09.zip |
Fix handling max warp pages.
-rw-r--r-- | Essentials/src/com/earth2me/essentials/commands/Commandwarp.java | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandwarp.java b/Essentials/src/com/earth2me/essentials/commands/Commandwarp.java index 94e63b7e7..4a739149f 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandwarp.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandwarp.java @@ -95,12 +95,19 @@ public class Commandwarp extends EssentialsCommand page = Integer.parseInt(args[0]); } + final int maxPages = (int)Math.ceil(warpNameList.size() / (double)WARPS_PER_PAGE); + + if (page > maxPages) + { + page = maxPages; + } + final int warpPage = (page - 1) * WARPS_PER_PAGE; final String warpList = StringUtil.joinList(warpNameList.subList(warpPage, warpPage + Math.min(warpNameList.size() - warpPage, WARPS_PER_PAGE))); if (warpNameList.size() > WARPS_PER_PAGE) { - sender.sendMessage(_("warpsCount", warpNameList.size(), page, (int)Math.ceil(warpNameList.size() / (double)WARPS_PER_PAGE))); + sender.sendMessage(_("warpsCount", warpNameList.size(), page, maxPages)); sender.sendMessage(_("warpList", warpList)); } else |