diff options
author | okamosy <okamosy@gmail.com> | 2011-08-23 22:58:19 +0100 |
---|---|---|
committer | okamosy <okamosy@gmail.com> | 2011-08-23 22:58:19 +0100 |
commit | 1a2fc307fdffde51a0ffae26e07caffdc39cbfbc (patch) | |
tree | 1ea800906f431c26473c39ee6ed8ca9f3d2c0d7c | |
parent | c374f474edb5ab6f3ef332f8fcb3a65ae87c96ee (diff) | |
download | Essentials-1a2fc307fdffde51a0ffae26e07caffdc39cbfbc.tar Essentials-1a2fc307fdffde51a0ffae26e07caffdc39cbfbc.tar.gz Essentials-1a2fc307fdffde51a0ffae26e07caffdc39cbfbc.tar.lz Essentials-1a2fc307fdffde51a0ffae26e07caffdc39cbfbc.tar.xz Essentials-1a2fc307fdffde51a0ffae26e07caffdc39cbfbc.zip |
updated to use corrected joinList function.
5 files changed, 20 insertions, 33 deletions
diff --git a/Essentials/src/com/earth2me/essentials/Util.java b/Essentials/src/com/earth2me/essentials/Util.java index 500aa0713..6565a9f57 100644 --- a/Essentials/src/com/earth2me/essentials/Util.java +++ b/Essentials/src/com/earth2me/essentials/Util.java @@ -11,7 +11,6 @@ import java.net.URL; import java.text.DecimalFormat; import java.text.DecimalFormatSymbols; import java.text.MessageFormat; -import java.util.ArrayList; import java.util.Calendar; import java.util.Enumeration; import java.util.GregorianCalendar; @@ -471,21 +470,33 @@ public class Util public static String joinList(Object... list) { + return joinList(", ", list); + } + + public static String joinList(String seperator, Object... list) + { StringBuilder buf = new StringBuilder(); for (Object each : list) { if (buf.length() > 0) { - buf.append(", "); + buf.append(seperator); } if(each instanceof List) { - buf.append(joinList(((List)each).toArray())); + buf.append(joinList(seperator, ((List)each).toArray())); } else { - buf.append(each.toString()); + try + { + buf.append(each.toString()); + } + catch (Exception e) + { + buf.append(each.toString()); + } } } return buf.toString(); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandhome.java b/Essentials/src/com/earth2me/essentials/commands/Commandhome.java index 3e4ee6178..2b285bfe7 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandhome.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandhome.java @@ -55,7 +55,7 @@ public class Commandhome extends EssentialsCommand } else { - user.sendMessage(Util.format("homes", homes.toString())); + user.sendMessage(Util.format("homes", Util.joinList(homes))); } } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandjails.java b/Essentials/src/com/earth2me/essentials/commands/Commandjails.java index b91a1c985..36eb633fc 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandjails.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandjails.java @@ -1,5 +1,6 @@ package com.earth2me.essentials.commands; +import com.earth2me.essentials.Util; import org.bukkit.Server; import org.bukkit.command.CommandSender; @@ -14,12 +15,6 @@ public class Commandjails extends EssentialsCommand @Override protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception { - StringBuilder jailList = new StringBuilder(); - for (String j : ess.getJail().getJails()) - { - jailList.append(j); - jailList.append(' '); - } - sender.sendMessage("§7" + jailList); + sender.sendMessage("§7" + Util.joinList(" ", ess.getJail().getJails())); } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandrepair.java b/Essentials/src/com/earth2me/essentials/commands/Commandrepair.java index e98deeab7..df0509f94 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandrepair.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandrepair.java @@ -55,16 +55,6 @@ public class Commandrepair extends EssentialsCommand String armor = repairItems(user.getInventory().getArmorContents()); - if (armor.length() > 0) - { - if (itemList.length() > 0) - { - itemList.append(", "); - } - - itemList.append(armor); - } - if (itemList.length() == 0) { user.sendMessage(Util.format("repairNone")); @@ -72,7 +62,7 @@ public class Commandrepair extends EssentialsCommand else { charge(user); - user.sendMessage(Util.format("repair", itemList.toString())); + user.sendMessage(Util.format("repair", Util.joinList(itemList))); } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandwarp.java b/Essentials/src/com/earth2me/essentials/commands/Commandwarp.java index 17d55faee..b93355f5a 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandwarp.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandwarp.java @@ -55,16 +55,7 @@ public class Commandwarp extends EssentialsCommand user.sendMessage(Util.format("warpsCount", warpNameList.size(), page, (int)Math.ceil(warpNameList.size() / (double)WARPS_PER_PAGE))); } final int warpPage = (page - 1) * WARPS_PER_PAGE; - final StringBuilder sb = new StringBuilder(); - for (int i = 0; i < Math.min(warpNameList.size() - warpPage, WARPS_PER_PAGE); i++) - { - if (i > 0) - { - sb.append(", "); - } - sb.append(warpNameList.get(i + warpPage)); - } - user.sendMessage(sb.toString()); + user.sendMessage(Util.joinList(warpNameList.subList(warpPage, warpPage+Math.min(warpNameList.size() - warpPage, WARPS_PER_PAGE)))); return; } if (args.length > 0) |