Matt-MX / DisplayNameTags

Replace boring old nametags with Display Entities!
MIT License
8 stars 0 forks source link

🏷️ Display Name Tags

Replace your players' boring old name tags with customizable ones based on text displays!

Configuration

Currently, you can customize default name tags and create grouped name tags.

You can also choose if players get to see their own name tags (Disabled by default).

API

Designed primarily for developers, the NameTags api gives you lightweight yet powerful control over how the plugin operates.

You can override default behaviours using the setDefaultProvider method, and the NameTagEntityCreateEvent to hook into a tag's creation. You can add your own features using the Trait api.


public void onEnable() {
    NameTags nameTags = NameTags.getInstance();

    // Override the default "base" settings of a tag.
    nameTags.getEntityManager()
        .setDefaultProvider((entity, meta) -> {
            meta.setText(Component.text(entity.getName()));
            /* ... */
        });
}

Here is an example where we can add an Item Display above the player's name tag by using the Trait system.


class MyCustomTrait extends Trait {
    // TODO create example by putting an ItemStack above a name tag.

    @Override
    public void onDisable() {
        // Clean up stuff
    }
}

class MyCustomListener implements Listener {

    @EventHandler
    public void onTagCreate(@NotNull NameTagEntityCreateEvent event) {
        if (!event.getBukkitEntity().getName().equals("MattMX")) return;

        event.getTraits().getOrAddTrait(MyCustomTrait.class, MyCustomTrait::new);
    }

}

Roadmap