Hello ladies and gentlemen! I am fairly new at coding, but I decided to tackle a simple name-plugin as a donator perk on my server, but recently I noticed a lot of lag was occuring at login. I'm not completely sure, but considering I use an onPlayerJoin, and I'm certainly capable of making mistakes, I will assume it is my plugin causing it. This is the code in question: Code:java @EventHandler public void onPlayerJoin(PlayerJoinEvent e){ if(e.getPlayer().getName() != null){ Player player = e.getPlayer(); if(this.getConfig().get(player.getName() + "prefix") != null && this.getConfig().get(player.getName() + "colour") != null && this.getConfig().get(player.getName() + "suffix") != null){ player.setDisplayName("&r" + this.getConfig().getString(player.getName() + "prefix") + this.getConfig().getString(player.getName() + "colour") + player.getName() + "&r" + this.getConfig().getString(player.getName() + "suffix")); } //prefix null else if(this.getConfig().get(player.getName() + "prefix") == null && this.getConfig().get(player.getName() + "colour") != null && this.getConfig().get(player.getName() + "suffix") != null){ player.setDisplayName(this.getConfig().getString(player.getName() + "colour") + player.getName() + "&r" + this.getConfig().getString(player.getName() + "suffix")); } //colour is null else if(this.getConfig().get(player.getName() + "prefix") != null && this.getConfig().get(player.getName() + "colour") == null && this.getConfig().get(player.getName() + "suffix") != null){ player.setDisplayName("&r" + this.getConfig().getString(player.getName() + "prefix") + player.getName() + "&r" + this.getConfig().getString(player.getName() + "suffix")); } //suffix is null else if(this.getConfig().get(player.getName() + "prefix") != null && this.getConfig().get(player.getName() + "colour") != null && this.getConfig().get(player.getName() + "suffix") == null){ player.setDisplayName("&r" + this.getConfig().getString(player.getName() + "prefix") + this.getConfig().getString(player.getName() + "colour") + player.getName()); } //prefix and colour is null else if(this.getConfig().get(player.getName() + "prefix") == null && this.getConfig().get(player.getName() + "colour") == null && this.getConfig().get(player.getName() + "suffix") != null){ player.setDisplayName(player.getName() + "&r" + this.getConfig().getString(player.getName() + "suffix")); } //prefix and suffix is null else if(this.getConfig().get(player.getName() + "prefix") == null && this.getConfig().get(player.getName() + "colour") != null && this.getConfig().get(player.getName() + "suffix") == null){ player.setDisplayName(this.getConfig().getString(player.getName() + "colour") + player.getName()); } //colour and suffix is null else if(this.getConfig().get(player.getName() + "prefix") != null && this.getConfig().get(player.getName() + "colour") == null && this.getConfig().get(player.getName() + "suffix") == null){ player.setDisplayName("&r" + this.getConfig().getString(player.getName() + "prefix") + player.getName()); } } } Basically, what the plugin does is it gives the people who have the permission the ability to change the colour of their name, and add a few letters before and after. I use this blurb of jambled coding mess to set their display name at login, and what it does is checks to see if the player has a prefix, suffix, or colour, and what to do accordingly.
Try assigning a variable to the string you get from the config so you only have to access the config once. String prefix = this.getConfig.getString(player.getName() + "prefix"); Also do it for the suffix and colour. Then just replace everywhere that this.getConfig.getString(player.getName() + "prefix") is with prefix. And do it for the other ones to.