mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-02-12 04:20:41 +00:00
Updated joinList to properly handle lists of lists.
This commit is contained in:
parent
dfdf49ac35
commit
2a1b19a8a8
5 changed files with 23 additions and 34 deletions
|
@ -11,6 +11,7 @@ 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;
|
||||
|
@ -470,17 +471,22 @@ public class Util
|
|||
|
||||
public static String joinList(Object... list)
|
||||
{
|
||||
final StringBuilder buf = new StringBuilder();
|
||||
boolean first = true;
|
||||
StringBuilder buf = new StringBuilder();
|
||||
for (Object each : list)
|
||||
{
|
||||
if (!first)
|
||||
if (buf.length() > 0)
|
||||
{
|
||||
buf.append(", ");
|
||||
|
||||
}
|
||||
first = false;
|
||||
buf.append(each);
|
||||
|
||||
if(each instanceof List)
|
||||
{
|
||||
buf.append(joinList(((List)each).toArray()));
|
||||
}
|
||||
else
|
||||
{
|
||||
buf.append(each.toString());
|
||||
}
|
||||
}
|
||||
return buf.toString();
|
||||
}
|
||||
|
@ -489,26 +495,4 @@ 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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ public class Commandpowertool extends EssentialsCommand
|
|||
}
|
||||
else
|
||||
{
|
||||
user.sendMessage(Util.format("powerToolList", Util.concat(powertools), itemName));
|
||||
user.sendMessage(Util.format("powerToolList", Util.joinList(powertools), itemName));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ public class Commandpowertool extends EssentialsCommand
|
|||
}
|
||||
|
||||
powertools.add(command);
|
||||
user.sendMessage(Util.format("powerToolAttach", Util.concat(powertools), itemName));
|
||||
user.sendMessage(Util.format("powerToolAttach", Util.joinList(powertools), itemName));
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -82,7 +82,12 @@ public class Commandspawnmob extends EssentialsCommand
|
|||
{
|
||||
8, 9
|
||||
};
|
||||
Location loc = (new TargetBlock(user, 300, 0.2, ignore)).getTargetBlock().getLocation();
|
||||
Block block = (new TargetBlock(user, 300, 0.2, ignore)).getTargetBlock();
|
||||
if(block == null) {
|
||||
user.sendMessage(Util.i18n("unableToSpawnMob"));
|
||||
return;
|
||||
}
|
||||
Location loc = block.getLocation();
|
||||
Location sloc = Util.getSafeDestination(loc);
|
||||
try
|
||||
{
|
||||
|
|
|
@ -146,7 +146,7 @@ kits = \u00a77Kits: {0}
|
|||
lightningSmited = \u00a77You have just been smited
|
||||
lightningUse = \u00a77Smiting {0}
|
||||
loadWarpError = Failed to load warp {0}
|
||||
loadinfo = Loaded {0} build {1} by {2}
|
||||
loadinfo = Loaded {0} build {1} by: {2}
|
||||
localFormat = Local: <{0}> {1}
|
||||
mailClear = \u00a7cTo mark your mail as read, type /mail clear
|
||||
mailCleared = \u00a77Mail Cleared!
|
||||
|
|
|
@ -146,7 +146,7 @@ kits = \u00a77Kits: {0}
|
|||
lightningSmited = \u00a77You have just been smited
|
||||
lightningUse = \u00a77Smiting {0}
|
||||
loadWarpError = Failed to load warp {0}
|
||||
loadinfo = Loaded {0} build {1} by {2}
|
||||
loadinfo = Loaded {0} build {1} by: {2}
|
||||
localFormat = Local: <{0}> {1}
|
||||
mailClear = \u00a7cTo mark your mail as read, type /mail clear
|
||||
mailCleared = \u00a77Mail Cleared!
|
||||
|
|
Loading…
Reference in a new issue