Having some trouble figuring out where to add the #replace("%player%", player.toString()) method. Any help? Code (Text): public void onJoin(PlayerJoinEvent e) { Player player = e.getPlayer(); for (int i = 0; i < this.plugin.getConfig().getStringList("Welcome Messages").size(); i++) { player.sendMessage(ChatColor.translateAlternateColorCodes('&', this.plugin.getConfig().getStringList("Welcome Messages").get(i))); e.setJoinMessage(null); } }
you could use java 8 stream api: Code (Java): getStringList("example").stream().map(s -> s.replace("%var%", varValue).collect(Collectors.toList()).forEach(s -> player.sendMessage(s));
Put it right after the get(i) Code (Text): for (int i = 0; i < this.plugin.getConfig().getStringList("Welcome Messages").size(); i++) { player.sendMessage(ChatColor.translateAlternateColorCodes('&', this.plugin.getConfig().getStringList("Welcome Messages").get(i))); e.setJoinMessage(null); } You do realize that you're setting the join message to null every single time you loop, right? you should consider moving that outside of your Forloop.
Not yet. May switch to the Java 8 API in a later date. Want to stay with what I'm most comfortable with for now. Once I start looking into the Java 8 API more I will go back over this