mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-08-07 21:13:53 +00:00
Added util function concat(List) and concat(string, list) to concatenate lists into a string.
Updated powertool to use new concat method.
This commit is contained in:
parent
c0d21b6044
commit
d2a3240905
2 changed files with 25 additions and 2 deletions
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue