diff --git a/src/main/java/lumien/custommainmenu/lib/StringReplacer.java b/src/main/java/lumien/custommainmenu/lib/StringReplacer.java index ebaaebb..0f26ca4 100644 --- a/src/main/java/lumien/custommainmenu/lib/StringReplacer.java +++ b/src/main/java/lumien/custommainmenu/lib/StringReplacer.java @@ -3,7 +3,6 @@ import java.lang.reflect.Field; import java.text.DateFormat; import java.text.SimpleDateFormat; -import java.util.Calendar; import java.util.Date; import java.util.Locale; @@ -14,7 +13,8 @@ public class StringReplacer { - static final String TIME_FORMAT = "HH:mm"; + static final String forgeVersion = ForgeVersion.getVersion(); + static final DateFormat dateFormat = DateFormat.getDateInstance(2, Locale.getDefault()); static final SimpleDateFormat timeFormat = new SimpleDateFormat("HH:mm"); static Field mcpversionField; public static String mcpversion; @@ -22,15 +22,13 @@ public class StringReplacer { public static String replacePlaceholders(String source) { int tModCount = Loader.instance().getModList().size(); int aModCount = Loader.instance().getActiveModList().size(); - Calendar calendar = Calendar.getInstance(); - String clock = timeFormat.format(calendar.getTime()); - DateFormat formatter = DateFormat.getDateInstance(2, Locale.getDefault()); - String date = formatter.format(new Date()); - Loader.instance(); - return source.replace("#date#", date).replace("#time#", clock).replace("#mcversion#", "1.7.10") + Date currentDate = new Date(); + String time = timeFormat.format(currentDate.getTime()); + String date = dateFormat.format(currentDate); + return source.replace("#date#", date).replace("#time#", time).replace("#mcversion#", "1.7.10") .replace("#fmlversion#", Loader.instance().getFMLVersionString()).replace("#mcpversion#", mcpversion) - .replace("#modsloaded#", tModCount + "").replace("#modsactive#", aModCount + "") - .replace("#forgeversion#", ForgeVersion.getVersion()) + .replace("#modsloaded#", Integer.toString(tModCount)) + .replace("#modsactive#", Integer.toString(aModCount)).replace("#forgeversion#", forgeVersion) .replace("#username#", Minecraft.getMinecraft().getSession().getUsername()); }