Class ChatPluginServerPlayer

java.lang.Object
me.remigio07.chatplugin.api.common.player.OfflinePlayer
me.remigio07.chatplugin.api.server.player.ChatPluginServerPlayer
All Implemented Interfaces:
ChatPluginPlayer

public abstract class ChatPluginServerPlayer extends OfflinePlayer implements ChatPluginPlayer
Represents a ChatPluginPlayer loaded on a server (Bukkit/Sponge) environment.
See Also:
  • Method Details

    • getVersion

      public VersionUtils.Version getVersion()
      Description copied from interface: ChatPluginPlayer
      Gets this player's version.
      Specified by:
      getVersion in interface ChatPluginPlayer
      Returns:
      Player's version
    • isBedrockPlayer

      public boolean isBedrockPlayer()
      Description copied from interface: ChatPluginPlayer
      Checks if this player is connected through a MultiPlatformIntegration.
      Specified by:
      isBedrockPlayer in interface ChatPluginPlayer
      Returns:
      Whether this player is using the Bedrock Edition
    • hasSocialspyEnabled

      public boolean hasSocialspyEnabled()
      Checks if this player has socialspy enabled.
      Returns:
      Whether socialspy is enabled
    • setSocialspyEnabled

      public void setSocialspyEnabled(boolean socialspyEnabled)
      Sets whether this player should have socialspy enabled.
      Parameters:
      socialspyEnabled - Whether socialspy is enabled
    • hasChatChannelSpyEnabled

      public boolean hasChatChannelSpyEnabled()
      Checks if this player has the chat channel spy enabled.
      Returns:
      Whether the chat channel spy is enabled
    • setChatChannelSpyEnabled

      public void setChatChannelSpyEnabled(boolean chatChannelSpyEnabled)
      Sets whether this player should have the chat channel spy enabled.
      Parameters:
      chatChannelSpyEnabled - Whether the chat channel spy is enabled
    • hasActionbarEnabled

      public boolean hasActionbarEnabled()
      Checks if actionbars should be displayed to this player.
      Returns:
      Whether their actionbar is enabled
    • setActionbarEnabled

      public void setActionbarEnabled(boolean actionbarEnabled)
      Sets whether actionbars should be displayed to this player.
      Parameters:
      actionbarEnabled - Whether their actionbar is enabled
    • getRank

      public Rank getRank()
      Gets this player's rank.
      Returns:
      Player's rank
    • getLanguage

      public Language getLanguage()
      Gets this player's language.
      Returns:
      Player's language
    • getScoreboard

      public Scoreboard getScoreboard()
      Gets this player's active scoreboard.

      Will return null if this player does not have an active scoreboard.

      Returns:
      Player's scoreboard
    • getBossbar

      public PlayerBossbar getBossbar()
      Gets this player's active bossbar.

      Will return null if this player does not have an active bossbar.

      Returns:
      Player's bossbar
    • getIPLookup

      public IPLookup getIPLookup(boolean generateIfNull)
      Gets an IP lookup for this player's IP address.

      Will return IPLookupManager.getDisabledFeatureConstructor() if !IPLookupManager.isEnabled() or !generateIfNull and there are no cached IP lookups for this player or an error occurrs.

      Note: this method might take some time to be executed: async calls are recommended.

      Parameters:
      generateIfNull - Whether to generate the lookup if it is not cached
      Returns:
      Lookup for this player
    • getObjective

      public ObjectiveAdapter getObjective()
      Gets this player's objective.
      Returns:
      Player's objective
    • getPlayerConnection

      public Object getPlayerConnection()
      Gets this player's connection's instance.
      Returns:
      Player's connection
    • getPing

      public int getPing()
      Gets this player's ping, in milliseconds.
      Returns:
      Player's ping
    • getID

      public int getID()
      Gets this player's PlayersDataType.ID from DataContainer.PLAYERS.
      Returns:
      Player's ID in the storage
    • getBans

      public int getBans()
      Returns:
      Player's bans in the storage
    • getAnticheatBans

      public short getAnticheatBans()
      Gets this player's anticheat bans from DataContainer.BANS.
      Returns:
      Player's anticheat bans in the storage
    • getWarnings

      public int getWarnings()
      Returns:
      Player's warnings in the storage
    • getAnticheatWarnings

      public short getAnticheatWarnings()
      Gets this player's anticheat warnings from DataContainer.WARNINGS.
      Returns:
      Player's anticheat warnings in the storage
    • getKicks

      public int getKicks()
      Returns:
      Player's kicks in the storage
    • getAnticheatKicks

      public short getAnticheatKicks()
      Gets this player's anticheat kicks from DataContainer.KICKS.
      Returns:
      Player's anticheat kicks in the storage
    • getMutes

      public int getMutes()
      Returns:
      Player's mutes in the storage
    • getAnticheatMutes

      public short getAnticheatMutes()
      Gets this player's anticheat mutes from DataContainer.MUTES.
      Returns:
      Player's anticheat mutes in the storage
    • getMessagesSent

      public int getMessagesSent()
      Returns:
      Player's messages sent in the storage
    • getAntispamInfractions

      public int getAntispamInfractions()
      Returns:
      Player's antispam infractions in the storage
    • getLoginTime

      public long getLoginTime()
      Gets this player's login time, in milliseconds.
      Returns:
      Player's login time
    • isVanished

      public boolean isVanished()
      Checks if this player is vanished.
      Returns:
      Whether this player is vanished
    • getLastCorrespondent

      public OfflinePlayer getLastCorrespondent()
      Gets this player's last correspondent.

      Will return null if this player does not have a correspondent. Returned value is the last player that has sent a private message to this player if PrivateMessagesManager.isReplyToLastSender(), otherwise it is the player to whom this player has last sent a private message.

      Note: the returned player may be vanished or in another server under the proxy and null does not represent the console - it is not possible to reply to it directly.

      Returns:
      Player's last correspondent
    • getChatColor

      public ChatColor getChatColor()
      Gets this player's chat's default color.

      Will return ChatColor.RESET if no chat color is set for this player.

      Returns:
      Player's chat's color
    • getEmojisTone

      public ChatColor getEmojisTone()
      Gets this player's emojis' tone.

      Will return ChatColor.RESET if no emojis' tone is set for this player.

      If that is the case, you may want to use the default tone instead.

      Returns:
      Player's emojis' tone
    • getWritingChannel

      public ChatChannel<? extends ChatChannelData> getWritingChannel()
      Gets the channel this player is writing in.

      Will return null if !ChatChannelsManager.isEnabled().

      Returns:
      Player's writing channel
    • getChannels

      public List<ChatChannel<? extends ChatChannelData>> getChannels()
      Gets the channels this player is listening to.
      Returns:
      Player's channels
    • joinChannel

      public boolean joinChannel(ChatChannel<? extends ChatChannelData> channel)
      Makes this player join the specified channel.

      Will do nothing and return false if they are already listening to it.

      Parameters:
      channel - Channel to join
      Returns:
      Whether the event has completed
      See Also:
    • leaveChannel

      public boolean leaveChannel(ChatChannel<? extends ChatChannelData> channel)
      Makes this player leave the specified channel.

      Will do nothing and return false if they are not listening to it.

      Parameters:
      channel - Channel to leave
      Returns:
      Whether the event has completed
      Throws:
      IllegalArgumentException - If getWritingChannel().equals(channel)
      See Also:
    • switchChannel

      public boolean switchChannel(ChatChannel<? extends ChatChannelData> channel)
      Makes this player switch channels for writing.

      Will call joinChannel(ChatChannel) if they are not listening to it and return false before executing ChatChannelSwitchEvent if that method returns false.

      Parameters:
      channel - Channel to switch to
      Returns:
      Whether the event has completed
      See Also:
    • getIgnoredPlayers

      public List<OfflinePlayer> getIgnoredPlayers()
      Returns:
      Ignored players' list
    • sendTranslatedMessage

      public void sendTranslatedMessage(String path, Object... args)
      Sends a translated message (with numeric placeholders) to this player.
      Parameters:
      path - Message's path
      args - Optional arguments (Utils.replaceNumericPlaceholders(String, Object...))
    • sendTranslatedMessage

      public void sendTranslatedMessage(String path, String[] placeholders, Object... args)
      Sends a translated message (with custom placeholders) to this player.
      Parameters:
      path - Message's path
      placeholders - Message's placeholders
      args - Optional arguments (Utils.replaceCustomPlaceholders(String, String[], Object...))
    • sendTitle

      public void sendTitle(String title, String subtitle)
      Calls sendTitle(String, String, int, int, int) specifying default values of 500, 3500 and 1000 milliseconds (or 10, 70 and 20 ticks).
      Parameters:
      title - Title to send
      subtitle - Subtitle to send
    • sendTitle

      public abstract void sendTitle(String title, String subtitle, int fadeIn, int stay, int fadeOut)
      Sends a title and a subtitle to this player.
      Parameters:
      title - Title to send
      subtitle - Subtitle to send
      fadeIn - Fading in effect's duration, in milliseconds
      stay - Stay effect's duration, in milliseconds
      fadeOut - Fading out effect's duration, in milliseconds
    • sendActionbar

      public abstract void sendActionbar(String actionbar)
      Sends an actionbar to this player.
      Parameters:
      actionbar - Actionbar to send
    • sendPacket

      @Deprecated public abstract void sendPacket(Object packet)
      Deprecated.
      Internal use only.
      Sends a packet to this player.
      Parameters:
      packet - Packet to send
    • openInventory

      public abstract void openInventory(InventoryAdapter inventory)
      Opens an inventory to this player.
      Parameters:
      inventory - Inventory to open
    • closeInventory

      public abstract void closeInventory()
      Closes the player's open inventory.
    • playSound

      public abstract void playSound(SoundAdapter sound)
      Plays a sound to this player.
      Parameters:
      sound - Sound to play
    • executeCommand

      public abstract void executeCommand(String command)
      Makes this player execute a command.
      Parameters:
      command - Command to execute without '/'
    • teleport

      public abstract void teleport(ChatPluginServerPlayer player)
      Teleports this player to another player.
      Parameters:
      player - Destination player
    • getDisplayName

      public abstract String getDisplayName()
      Gets this player's display name.

      It can be changed by other plugins and may include formatting codes.

      Returns:
      Player's display name
    • getWorld

      public abstract String getWorld()
      Gets this player's world's name.
      Returns:
      Player's world's name
    • getX

      public abstract double getX()
      Gets this player's location's X coordinate.
      Returns:
      Player's X coord
    • getY

      public abstract double getY()
      Gets this player's location's Y coordinate.
      Returns:
      Player's Y coord
    • getZ

      public abstract double getZ()
      Gets this player's location's Z coordinate.
      Returns:
      Player's Z coord
    • getDistance

      public abstract double getDistance(double x, double y, double z)
      Gets this player's distance from the specified location.
      Parameters:
      x - X coord
      y - Y coord
      z - Z coord
      Returns:
      Player's distance
    • getLocale

      public abstract Locale getLocale()
      Gets this player's locale set in their game's settings.
      Returns:
      Player's locale
    • setChatColor

      public abstract void setChatColor(ChatColor chatColor)
      Sets this player's chat's default color.

      Specify ChatColor.RESET to reset it and make it appear as their rank's Rank.getChatColor() when they type in chat.

      Parameters:
      chatColor - Player's chat's color
      Throws:
      IllegalArgumentException - If ChatColor.isFormatCode()
    • setEmojisTone

      public abstract void setEmojisTone(ChatColor emojisTone)
      Sets this player's emojis' tone.

      Specify ChatColor.RESET to reset it and make it appear as the default tone.

      Parameters:
      emojisTone - Player's emojis' tone
      Throws:
      IllegalArgumentException - If ChatColor.isFormatCode()