Skip to content

Instantly share code, notes, and snippets.

@stuntguy3000
Created January 19, 2015 10:32
Show Gist options
  • Save stuntguy3000/0a1e20e805a68b249422 to your computer and use it in GitHub Desktop.
Save stuntguy3000/0a1e20e805a68b249422 to your computer and use it in GitHub Desktop.
public static String formulate(String message, Object... vars) {
return StringUtil.colour('&', Lang.PREFIX + String.format(message, vars));
}
public static String formulateConsole(String message, Object... vars) {
return ChatColor.stripColor(Lang.PREFIX + String.format(message, vars)).replaceAll("[^\\x00-\\x7f]", "").trim().replaceAll(" +", " ");
}
public static String formulateRaw(String message, Object... vars) {
return StringUtil.colour('&', String.format(message, vars));
}
public static void load() throws IllegalAccessException, NoSuchFieldException, IOException {
YamlConfiguration config = ConfigHandler.getConfig(ConfigHandler.ConfigType.LANG);
Lang messageInstance = new Lang();
for (Field field : messageInstance.getClass().getFields()) {
if (!config.contains(field.getName())) {
config.set(field.getName(), field.get(messageInstance.getClass()));
}
}
for (String message : config.getKeys(false)) {
try {
Field field = Lang.class.getDeclaredField(message);
field.setAccessible(true);
field.set(null, config.getString(message));
} catch (NoSuchFieldException ex) {
config.set(message, null);
config.save(ConfigHandler.getFile(ConfigHandler.ConfigType.LANG));
}
}
try {
config.save(ConfigHandler.getFile(ConfigHandler.ConfigType.LANG));
} catch (IOException e) {
e.printStackTrace();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment