public void setup() { FileConfiguration f = SettingsManager.getInstance().getMessageConfig(); prefix.put(PrefixType.MAIN, MessageUtil.replaceColors(f.getString("prefix.main"))); prefix.put(PrefixType.INFO, MessageUtil.replaceColors(f.getString("prefix.states.info"))); prefix.put(PrefixType.WARNING, MessageUtil.replaceColors(f.getString("prefix.states.warning"))); prefix.put(PrefixType.ERROR, MessageUtil.replaceColors(f.getString("prefix.states.error"))); }
/** * SendMessage * * <p>Loads a Message from messages.yml, converts its colors and replaces vars in the form of * {$var} with its correct values, then sends to the player, adding the correct prefix * * @param type Type of message to send * @param input What message you want to send from messages.yml * @param player Player you want to send message to * @param vars */ public void sendFMessage(PrefixType type, String input, Player player, String... args) { String msg = SettingsManager.getInstance().getMessageConfig().getString("messages." + input); boolean enabled = SettingsManager.getInstance() .getMessageConfig() .getBoolean("messages." + input + "_enabled", true); if (msg == null) { player.sendMessage(ChatColor.RED + "Failed to load message for messages." + input); return; } if (!enabled) return; if (args != null && args.length != 0) { msg = MessageUtil.replaceVars(msg, args); } msg = MessageUtil.replaceColors(msg); player.sendMessage(prefix.get(PrefixType.MAIN) + " " + prefix.get(type) + msg); }