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();
// …