summaryrefslogtreecommitdiffstats
path: root/Essentials/src
diff options
context:
space:
mode:
authorokamosy <okamosy@gmail.com>2011-08-23 19:47:50 +0100
committerKHobbits <rob@khobbits.co.uk>2011-08-23 23:40:41 +0100
commit18b6c3436f8526b6dce6ec49327b9f9aa0833326 (patch)
tree8d6fc8a28e0fdbc9681e4c94792716288644584a /Essentials/src
parentab6bc94456e170d5d5d52f94c5a8448ef7f385b6 (diff)
downloadEssentials-18b6c3436f8526b6dce6ec49327b9f9aa0833326.tar
Essentials-18b6c3436f8526b6dce6ec49327b9f9aa0833326.tar.gz
Essentials-18b6c3436f8526b6dce6ec49327b9f9aa0833326.tar.lz
Essentials-18b6c3436f8526b6dce6ec49327b9f9aa0833326.tar.xz
Essentials-18b6c3436f8526b6dce6ec49327b9f9aa0833326.zip
Updated joinList to properly handle lists of lists.
Diffstat (limited to 'Essentials/src')
-rw-r--r--Essentials/src/com/earth2me/essentials/Util.java42
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandpowertool.java4
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java7
-rw-r--r--Essentials/src/messages.properties2
-rw-r--r--Essentials/src/messages_en.properties2
5 files changed, 23 insertions, 34 deletions
diff --git a/Essentials/src/com/earth2me/essentials/Util.java b/Essentials/src/com/earth2me/essentials/Util.java
index e850f9732..500aa0713 100644
--- a/Essentials/src/com/earth2me/essentials/Util.java
+++ b/Essentials/src/com/earth2me/essentials/Util.java
@@ -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();
}
@@ -488,27 +494,5 @@ public class Util
public static String capitalCase(String s)
{
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 054419a86..4e85d2aeb 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", 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
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java b/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java
index 9514bc767..17081e349 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java
@@ -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
{
diff --git a/Essentials/src/messages.properties b/Essentials/src/messages.properties
index c382a449f..52cefd453 100644
--- a/Essentials/src/messages.properties
+++ b/Essentials/src/messages.properties
@@ -147,7 +147,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!
diff --git a/Essentials/src/messages_en.properties b/Essentials/src/messages_en.properties
index 288500947..c96c9ecb7 100644
--- a/Essentials/src/messages_en.properties
+++ b/Essentials/src/messages_en.properties
@@ -147,7 +147,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!