@Test public void testMessageRetrieval(){ String expected = "&6Game starting in 10"; String test = MessageUtil.replaceVars(messageConfig.getString("messages.game.countdown", ""), "t-10"); assertThat(test, is(expected)); }
public static String replaceVars(String msg, HashMap<String, String> vars){ boolean error = false; for(String s:vars.keySet()){ try{ msg.replace("{$"+s+"}", vars.get(s)); }catch(Exception e){ MessageManager.getInstance().debugConsole("Failed to replace string vars. Error on " + s); error = true; } } if(error){ MessageManager.getInstance().debugConsole("Error replacing vars in message: " + msg); MessageManager.getInstance().debugConsole("Vars: " + vars.toString()); MessageManager.getInstance().debugConsole("Vars Cache: " + varcache.toString()); } return msg; }
MessageUtil { public static String replaceVars(String msg, HashMap<String, String> vars){ boolean error = false; for(String s:vars.keySet()){ try{ msg.replace("{$"+s+"}", vars.get(s)); }catch(Exception e){ MessageManager.getInstance().debugConsole("Failed to replace string vars. Error on " + s); error = true; } } if(error){ MessageManager.getInstance().debugConsole("Error replacing vars in message: " + msg); MessageManager.getInstance().debugConsole("Vars: " + vars.toString()); MessageManager.getInstance().debugConsole("Vars Cache: " + varcache.toString()); } return msg; } }
MessageUtil { public static String replaceVars(String msg, HashMap<String, String> vars){ boolean error = false; for(String s:vars.keySet()){ try{ msg.replace("{$"+s+"}", vars.get(s)); }catch(Exception e){ MessageManager.getInstance().debugConsole("Failed to replace string vars. Error on " + s); error = true; } } if(error){ MessageManager.getInstance().debugConsole("Error replacing vars in message: " + msg); MessageManager.getInstance().debugConsole("Vars: " + vars.toString()); MessageManager.getInstance().debugConsole("Vars Cache: " + varcache.toString()); } return msg; }  }
MessageUtil { public static String replaceVars(String msg, HashMap<String, String> vars){ boolean error = false; for(String s:vars.keySet()){ try{ msg.replace("{$"+s+"}", vars.get(s)); }catch(Exception e){ MessageManager.getInstance().debugConsole("Failed to replace string vars. Error on " + s); error = true; } } if(error){ MessageManager.getInstance().debugConsole("Error replacing vars in message: " + msg); MessageManager.getInstance().debugConsole("Vars: " + vars.toString()); MessageManager.getInstance().debugConsole("Vars Cache: " + varcache.toString()); } return msg; }  static String replaceVars(String msg, HashMap<String, String> vars); static String replaceVars(String msg, String ...vars); }
MessageUtil { public static String replaceVars(String msg, HashMap<String, String> vars){ boolean error = false; for(String s:vars.keySet()){ try{ msg.replace("{$"+s+"}", vars.get(s)); }catch(Exception e){ MessageManager.getInstance().debugConsole("Failed to replace string vars. Error on " + s); error = true; } } if(error){ MessageManager.getInstance().debugConsole("Error replacing vars in message: " + msg); MessageManager.getInstance().debugConsole("Vars: " + vars.toString()); MessageManager.getInstance().debugConsole("Vars Cache: " + varcache.toString()); } return msg; }  static String replaceVars(String msg, HashMap<String, String> vars); static String replaceVars(String msg, String ...vars);  }