From 6423e8d2e58d9b03bc81918cd551fa3ac4245b22 Mon Sep 17 00:00:00 2001 From: graywolf336 Date: Wed, 25 Dec 2013 22:41:01 -0600 Subject: [PATCH] If the location is empty, don't try it. If the language string doesn't exist, then don't try to parse it either and return an empty string. --- src/main/java/com/graywolf336/jail/JailIO.java | 4 +++- src/main/java/com/graywolf336/jail/beans/Prisoner.java | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/graywolf336/jail/JailIO.java b/src/main/java/com/graywolf336/jail/JailIO.java index a18be1c..6dadd09 100644 --- a/src/main/java/com/graywolf336/jail/JailIO.java +++ b/src/main/java/com/graywolf336/jail/JailIO.java @@ -88,11 +88,13 @@ public class JailIO { * * @param langString Which {@link LangString} we should be getting to send. * @param variables All the variables to replace, in order from 0 to however many. - * @return The message as a colorful message. + * @return The message as a colorful message or an empty message if that isn't defined in the language file. */ public String getLanguageString(LangString langString, String... variables) { String message = lang.getString("language." + langString.toString().toLowerCase()); + if(message == null) return ""; + for (int i = 0; i < variables.length; i++) { message = message.replaceAll("%" + i + "%", variables[i]); } diff --git a/src/main/java/com/graywolf336/jail/beans/Prisoner.java b/src/main/java/com/graywolf336/jail/beans/Prisoner.java index 0f996bf..7cad3f5 100644 --- a/src/main/java/com/graywolf336/jail/beans/Prisoner.java +++ b/src/main/java/com/graywolf336/jail/beans/Prisoner.java @@ -123,6 +123,7 @@ public class Prisoner { /** Sets the previous location of this player from a comma separated string. */ public void setPreviousPosition(String location) { if(location == null) return; + if(location.isEmpty()) return; String[] s = location.split(","); this.previousPosition = new Location(Bukkit.getWorld(s[0]),