-
Notifications
You must be signed in to change notification settings - Fork 0
Nametag
Ever wonder how to change the overhead name of a player on your server? Easy! NR-Core has a framework for that aswell.
First, you need a Listener with the PlayerJoinEvent
PlayerJoinListener.java
public class PlayerJoinListener implements Listener {
@EventHandler
public void onJoin(PlayerJoinEvent e) {
int ranking = 1;
String prefix = ChatColor.RED + "The Cool";
String suffix = ChatColor.GOLD + "III";
ChatColor color = ChatColor.GREEN;
new PlayerNameTag().initializePlayerNameTag(e.getPlayer(), ranking, prefix, suffix, color);
}
}
Wow, let's take this step by step. First we specify the player we are targeting, in our case it's e.getPlayer()
.
Next we give our player a ranking in the tablist. The higher number = higher ranking, 1 being the highest.
After that we supply it with a prefix for our player. This can be null.
Then we also give it a suffix. This can be null
Lastly, we give the color of our player's name in the tablist. This can be null which give's it the defualt color.
And that's it! You can get these values from a permissions manager like LuckPerms or Vault. Want to Sync your minecraft ranks to your discord ranks? Check out this - shameless plug