net.minestom.server.network.UuidProvider Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of minestom-snapshots Show documentation
Show all versions of minestom-snapshots Show documentation
1.20.4 Lightweight Minecraft server
package net.minestom.server.network;
import net.minestom.server.network.player.PlayerConnection;
import org.jetbrains.annotations.NotNull;
import java.util.UUID;
/**
* Used when you want to provide your own {@link UUID} object for players instead of using the default one.
*
* Sets with {@link ConnectionManager#setUuidProvider(UuidProvider)}.
*/
@FunctionalInterface
public interface UuidProvider {
/**
* Called when a new {@link UUID} is requested.
*
* The {@link UUID} does not need to be persistent between restart, but being sure that all players have a different
* one is good practice. Otherwise, undefined behavior can happen.
*
* @param playerConnection the connection who requires a new unique id
* @param username the username given by the connection
* @return the new {@link UUID} for the player
*/
@NotNull UUID provide(@NotNull PlayerConnection playerConnection, @NotNull String username);
}