1 minute estimated read time

Custom players

Below is an example for a custom player using vital-players.
First you need to add this to your application configuration (application.yaml, application.properties, etc.) in your project's src/main/resources location.

src/main/resources/application.yaml
vital:
    players:
        player-class-name: fully.qualified.class.name.MyPlayer

Then you can use the example below:

MyPlayer.java
public class MyPlayer extends VitalPlayer.Spigot {
    private String myString;
    private boolean myBoolean;

    public MyPlayer(Player player) {
        super(player);
    }

    // Getters and setters
}

Vital automatically creates an instance of your custom player when a player joins your server and automatically deletes it when your player leaves.

Now use the VitalPlayerRepository bean to get your player.

final var myPlayer = vitalPlayerRepository.findById(MyPlayer.class, myPlayerUniqueId);
myPlayer.getMyString();
myPlayer.getMyBoolean();
// …

Found an issue?

Help us improve the documentation by reporting typos, missing information, or anything confusing.

Don't worry, we will auto-fill most of the annoying fields.

Create GitHub issue

This site and the Vital framework were built with ❤️ by Mike Neumann