Interface IPlayerRegistry


public interface IPlayerRegistry
Maintains a save specific list of userids and username combinations this greatly simplifies storage internally and gives a common place to look up and get IDs for the security framework.
  • Method Summary

    Modifier and Type
    Method
    Description
    static @Nullable net.minecraft.server.level.ServerPlayer
    getConnected(net.minecraft.server.MinecraftServer server, int playerId)
    Convenience method to get a connected ServerPlayer for a given ME player id.
    getMapping(net.minecraft.server.MinecraftServer server)
    Gets the mapping between GameProfile ids and AE2's player ids for the given server.
    static @Nullable IPlayerRegistry
    getMapping(net.minecraft.world.level.Level level)
    Convenience method to get the player registry that's associated with the server that hosts the given level.
    default int
    getPlayerId(com.mojang.authlib.GameProfile gameProfile)
    Queries AE2's internal player ID for the given GameProfile.
    int
    getPlayerId(UUID profileId)
    Queries AE2's internal player ID for the given profile UUID.
    static int
    getPlayerId(net.minecraft.server.level.ServerPlayer player)
    Convenience method to get the ME player id associated with a connected player.
    @Nullable UUID
    getProfileId(int playerId)
    Find the stored profile UUID that is stored for the given ME player id, if any.
  • Method Details

    • getMapping

      static IPlayerRegistry getMapping(net.minecraft.server.MinecraftServer server)
      Gets the mapping between GameProfile ids and AE2's player ids for the given server.
    • getMapping

      @Nullable static @Nullable IPlayerRegistry getMapping(net.minecraft.world.level.Level level)
      Convenience method to get the player registry that's associated with the server that hosts the given level. Null will be returned for client-side levels.
    • getPlayerId

      static int getPlayerId(net.minecraft.server.level.ServerPlayer player)
      Convenience method to get the ME player id associated with a connected player.
    • getConnected

      @Nullable static @Nullable net.minecraft.server.level.ServerPlayer getConnected(net.minecraft.server.MinecraftServer server, int playerId)
      Convenience method to get a connected ServerPlayer for a given ME player id. This can return null for two reasons: the ME player id is unknown, or the player associated with the given ID is not logged onto the server.
    • getPlayerId

      default int getPlayerId(com.mojang.authlib.GameProfile gameProfile)
      Queries AE2's internal player ID for the given GameProfile. If AE2 has not assigned an ID to that player yet, it will be automatically assigned.

      Returns:
      -1 if the given profile has no id set. Usually, the game should create a stable UUID even for offline players by hashing their name.
    • getPlayerId

      int getPlayerId(UUID profileId)
      Queries AE2's internal player ID for the given profile UUID. If AE2 has not assigned an ID to that player yet, it will be automatically assigned.
    • getProfileId

      @Nullable @Nullable UUID getProfileId(int playerId)
      Find the stored profile UUID that is stored for the given ME player id, if any.
      Returns:
      Null if no such player is known.