Interface CarbonPlayer

All Superinterfaces:
Audience, Identified, Pointered

Generic abstraction for players.
Since:
2.0.0
  • Method Details

    • distanceSquaredFrom

      double distanceSquaredFrom(CarbonPlayer other)
      Returns the distance from the other CarbonPlayer, or -1 if the players are not in the same world.
      Parameters:
      other - the other player
      Returns:
      the distance from the other player, or -1
      Since:
      3.0.0
    • sameWorldAs

      boolean sameWorldAs(CarbonPlayer other)
      Returns if both players are in the same world or server.
      Parameters:
      other - the other player
      Returns:
      if both players are in the same world/server
      Since:
      3.0.0
    • username

      String username()
      Gets the player's username.
      Returns:
      the player's username
      Since:
      2.0.0
    • displayName

      Component displayName()
      Returns the player's display name.

      The display name is the effective or displayed name of a player. When the player has a nickname set, either through Carbon or the platform, it will be reflected here. Else, a plain text component representing the player's name may be returned.

      Returns:
      the player's display name
      Since:
      3.0.0
    • hasNickname

      boolean hasNickname()
      Checks if the player has a nickname set.

      Will always return false when Carbon's nickname management is disabled.

      Returns:
      if the player has a nickname set
      Since:
      3.0.0
      See Also:
    • nickname

      @Nullable Component nickname()
      Gets the player's nickname, shown in places like chat and tab menu.

      Will always return null when Carbon's nickname management is disabled.

      Returns:
      the player's nickname
      Since:
      3.0.0
      See Also:
    • nickname

      void nickname(@Nullable Component nickname)
      Sets the player's nickname.

      Setting null will remove any current nickname.

      Won't have any visible effect when Carbon's nickname management is disabled.

      Parameters:
      nickname - the new nickname
      Since:
      3.0.0
      See Also:
    • uuid

      UUID uuid()
      The player's UUID, often used for identification purposes.
      Returns:
      the player's UUID
      Since:
      2.0.0
    • createItemHoverComponent

      @Nullable Component createItemHoverComponent(InventorySlot slot)
      Creates the chat component for the item in the InventorySlot, or null if the slot is empty.
      Parameters:
      slot - the inventory slot containing the item
      Returns:
      the chat component for the item in the slot, or null if the slot is empty
      Since:
      2.0.0
    • locale

      @Nullable Locale locale()
      The player's locale.
      Returns:
      the player's locale, or null if offline
      Since:
      2.0.0
    • selectedChannel

      @Nullable ChatChannel selectedChannel()
      The player's selected channel, or null if one isn't set.
      Returns:
      the player's selected channel
      Since:
      2.0.0
    • selectedChannel

      void selectedChannel(@Nullable ChatChannel chatChannel)
      Sets the player's selected channel.
      Parameters:
      chatChannel - the channel
      Since:
      2.0.0
    • channelForMessage

      CarbonPlayer.ChannelMessage channelForMessage(Component message)
      Determines which channel the message should go to, and removes any channel prefixes from the message.
      Parameters:
      message - the message to be sent
      Returns:
      the channel and message
      Since:
      3.0.0
    • hasPermission

      boolean hasPermission(String permission)
      Checks if the player has the specified permission.
      Parameters:
      permission - the permission to check
      Returns:
      if the player has the permission
      Since:
      2.0.0
    • primaryGroup

      String primaryGroup()
      Returns the player's primary group.
      Returns:
      the player's primary group
      Since:
      2.0.0
    • groups

      List<String> groups()
      Returns the complete list of groups the player is in.
      Returns:
      the groups the player is in
      Since:
      2.0.0
    • muted

      boolean muted()
      Returns if the player is muted.
      Returns:
      if the player is muted
      Since:
      2.0.0
    • muteExpiration

      long muteExpiration()
      The time the mute will expire, in epoch millis.
      Returns:
      the mute expiration time
      Since:
      3.0.0
    • muted

      void muted(boolean muted)
      Mutes and unmutes the player.
      Parameters:
      muted - if the player is now muted
      Since:
      2.0.0
    • muteExpiration

      void muteExpiration(long epochMillis)
      Sets the epoch time the player's mute will expire.
      Parameters:
      epochMillis - the expiration time
      Since:
      3.0.0
    • ignoring

      Set<UUID> ignoring()
      Gets the ids of the players this player is currently ignoring.
      Returns:
      the players currently ignored
      Since:
      3.0.0
    • ignoring

      boolean ignoring(UUID player)
      Checks if the other player is being ignored by this player.
      Parameters:
      player - the potential source of a message
      Returns:
      if this player is ignoring the sender
      Since:
      2.0.5
    • ignoring

      boolean ignoring(CarbonPlayer player)
      Checks if the other player is being ignored by this player.
      Parameters:
      player - the potential source of a message
      Returns:
      if this player is ignoring the sender
      Since:
      2.0.0
    • ignoring

      void ignoring(UUID player, boolean nowIgnoring)
      Adds the player to and removes the player from the ignore list.
      Parameters:
      player - the player to be added/removed
      nowIgnoring - if the player should be ignored
      Since:
      2.0.0
    • ignoring

      void ignoring(CarbonPlayer player, boolean nowIgnoring)
      Adds the player to and removes the player from the ignore list.
      Parameters:
      player - the player to be added/removed
      nowIgnoring - if the player should be ignored
      Since:
      2.0.0
    • deafened

      boolean deafened()
      Returns if the player is deafened and unable to read messages.
      Returns:
      if the player is deafened
      Since:
      2.0.0
    • deafened

      void deafened(boolean deafened)
      Deafens and undeafens the player.
      Since:
      2.0.0
    • spying

      boolean spying()
      Returns if the player is spying on messages and able to read muted/private messages.
      Returns:
      if the player is spying on messages
      Since:
      2.0.0
    • spying

      void spying(boolean spying)
      Sets and unsets the player's ability to spy.
      Since:
      2.0.0
    • ignoringDirectMessages

      boolean ignoringDirectMessages()
      Controls if the player should receive direct messages or if they should be hidden.
      Returns:
      if the player is ignoring direct messages
      Since:
      3.0.0
    • ignoringDirectMessages

      void ignoringDirectMessages(boolean ignoring)
      Sets whether the player should receive direct messages or if they should be hidden.
      Parameters:
      ignoring - if the player is ignoring direct messages
      Since:
      3.0.0
    • sendMessageAsPlayer

      void sendMessageAsPlayer(String message)
      Sends the message as the player.
      Parameters:
      message - the message to be sent
      Since:
      2.0.0
    • online

      boolean online()
      Returns whether the player is online.
      Returns:
      if the player is online.
      Since:
      2.0.0
    • whisperReplyTarget

      @Nullable UUID whisperReplyTarget()
      The UUID of the player that replies will be sent to.
      Returns:
      the player's reply target
      Since:
      2.0.0
    • whisperReplyTarget

      void whisperReplyTarget(@Nullable UUID uuid)
      Sets the whisper reply target for this player.
      Parameters:
      uuid - the uuid of the reply target
      Since:
      2.0.0
    • lastWhisperTarget

      @Nullable UUID lastWhisperTarget()
      The last player this player has whispered.
      Returns:
      the player's last whisper target
      Since:
      2.0.0
    • lastWhisperTarget

      void lastWhisperTarget(@Nullable UUID uuid)
      Sets the last player this player has whispered.
      Parameters:
      uuid - the uuid of the whisper target
      Since:
      2.0.0
    • vanished

      boolean vanished()
      If this player is vanished in another supported plugin. Other players will be unaware of this player. There is no way to set this state through Carbon, we do not store this information; but merely bridge it.
      Returns:
      If this player is vanished in another plugin.
      Since:
      2.0.0
    • awareOf

      boolean awareOf(CarbonPlayer other)
      Whether this player can see the other player.
      Parameters:
      other - the other, potentially vanished, player
      Returns:
      if this player is aware of the other player
      Since:
      2.0.0
    • leftChannels

      List<Key> leftChannels()
      A list of all the channels the player has left using the leave command.

      The returned collection is immutable, use joinChannel(ChatChannel) and leaveChannel(ChatChannel) to mutate.

      Returns:
      a list of the channels.
      Since:
      3.0.0
    • joinChannel

      void joinChannel(ChatChannel channel)
      Join a channel for this player if they have left it.
      Parameters:
      channel - the channel to join.
      Since:
      3.0.0
    • leaveChannel

      void leaveChannel(ChatChannel channel)
      Leave a channel for this player.
      Parameters:
      channel - the channel to leave.
      Since:
      3.0.0
    • party

      Get this player's current Party.
      Returns:
      party future
      Since:
      3.0.0
    • applyOptionalChatFilters

      boolean applyOptionalChatFilters()
      Whether the optional chat filters apply to messages send to this player or not.
      Returns:
      if this player's using the optional chat filters
      Since:
      3.0.0
    • applyOptionalChatFilters

      void applyOptionalChatFilters(boolean applyOptionalChatFilters)
      Whether the optional chat filters apply to messages send to this player or not.
      Parameters:
      applyOptionalChatFilters - if this player's using the optional chat filters
      Since:
      3.0.0