diff options
author | okamosy <okamosy@gmail.com> | 2011-08-22 22:10:23 +0100 |
---|---|---|
committer | KHobbits <rob@khobbits.co.uk> | 2011-08-23 23:40:27 +0100 |
commit | f12a14d7f7bbc59823d124e1ffa2e85bf1a1239a (patch) | |
tree | 72688e906088e6aa828a4e180163665d9051c59d | |
parent | 38aa85dd0cf1c208dadb9e4b7947a7c00cb33f13 (diff) | |
download | Essentials-f12a14d7f7bbc59823d124e1ffa2e85bf1a1239a.tar Essentials-f12a14d7f7bbc59823d124e1ffa2e85bf1a1239a.tar.gz Essentials-f12a14d7f7bbc59823d124e1ffa2e85bf1a1239a.tar.lz Essentials-f12a14d7f7bbc59823d124e1ffa2e85bf1a1239a.tar.xz Essentials-f12a14d7f7bbc59823d124e1ffa2e85bf1a1239a.zip |
Added util function concat(List) and concat(string, list) to concatenate lists into a string.
Updated powertool to use new concat method.
-rw-r--r-- | Essentials/src/com/earth2me/essentials/Util.java | 23 | ||||
-rw-r--r-- | Essentials/src/com/earth2me/essentials/commands/Commandpowertool.java | 4 |
2 files changed, 25 insertions, 2 deletions
diff --git a/Essentials/src/com/earth2me/essentials/Util.java b/Essentials/src/com/earth2me/essentials/Util.java index 82231cb06..e850f9732 100644 --- a/Essentials/src/com/earth2me/essentials/Util.java +++ b/Essentials/src/com/earth2me/essentials/Util.java @@ -14,6 +14,7 @@ import java.text.MessageFormat; import java.util.Calendar; import java.util.Enumeration; import java.util.GregorianCalendar; +import java.util.List; import java.util.Locale; import java.util.MissingResourceException; import java.util.ResourceBundle; @@ -488,4 +489,26 @@ public class Util { return s.toUpperCase().charAt(0) + s.toLowerCase().substring(1); } + + public static String concat(List list) + { + return concat(",", list); + } + + public static String concat(String seperator, List list) + { + StringBuilder sb = new StringBuilder(); + + for(Object item : list) + { + if(sb.length() > 0) + { + sb.append(seperator); + } + + sb.append(item.toString()); + } + + return sb.toString(); + } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandpowertool.java b/Essentials/src/com/earth2me/essentials/commands/Commandpowertool.java index bc1ccd801..054419a86 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandpowertool.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandpowertool.java @@ -39,7 +39,7 @@ public class Commandpowertool extends EssentialsCommand } else { - user.sendMessage(Util.format("powerToolList", powertools.toString(), itemName)); + user.sendMessage(Util.format("powerToolList", Util.concat(powertools), itemName)); } return; } @@ -85,7 +85,7 @@ public class Commandpowertool extends EssentialsCommand } powertools.add(command); - user.sendMessage(Util.format("powerToolAttach", powertools.toString(), itemName)); + user.sendMessage(Util.format("powerToolAttach", Util.concat(powertools), itemName)); } } else |