Interface nChatAPI


public interface nChatAPI
nChat API interface.
  • Method Details

    • getApi

      @Nonnull static nChatAPI getApi()
      Returns the nLogin api.
      Throws:
      IllegalStateException - if the api has not yet been instantiated
    • isLoaded

      @Deprecated default boolean isLoaded()
      Deprecated.
      It checks if the api is ready to be used.
      Since:
      API v1
    • getVersion

      @Nonnull String getVersion()
      Returns the version of the plugin.
      Since:
      API v1
    • getApiVersion

      int getApiVersion()
      Returns the version of the api.
      Since:
      API v1
    • getSession

      PlayerSession getSession(@Nonnull org.bukkit.entity.Player player)
      Returns a player's session.
      Parameters:
      player - the owner of the session
      Throws:
      IllegalStateException - if the player session is not loaded
      Since:
      API v2
    • getGlobalTag

      @Nullable GlobalTag getGlobalTag(@Nonnull String tag)
      Returns the content of a global nChat tag.
      Parameters:
      tag - the desired tag without {}
      Returns:
      the GlobalTag instance (can be null if it doesn't exist)
      Throws:
      IllegalStateException - if the API is not yet fully loaded
      Since:
      API v1
    • removeGlobalTag

      default boolean removeGlobalTag(@Nonnull String tag)
      Deletes a global nChat tag.
      Parameters:
      tag - the desired tag without {}
      Returns:
      true if the tag existed before.
      Throws:
      IllegalStateException - if the API is not yet fully loaded
      Since:
      API v1
    • setGlobalTag

      default boolean setGlobalTag(@Nonnull String tag, @Nullable GlobalTag globalTag)
      Defines a global nChat tag.
      Parameters:
      tag - the desired tag without {}
      globalTag - the global tag translator.
      Returns:
      true when the tag already exists.
      Throws:
      IllegalStateException - if the API is not yet fully loaded
      Since:
      API v1
    • setGlobalTag

      boolean setGlobalTag(@Nonnull String tag, @Nullable GlobalTag globalTag, boolean override)
      Defines a global nChat tag.
      Parameters:
      tag - the desired tag without {}
      globalTag - the global tag translator
      override - if true, it adds the tag even if it already exists
      Returns:
      true when the tag already exists
      Throws:
      IllegalStateException - if the API is not yet fully loaded
      Since:
      API v1
    • replacePlaceholders

      @Nonnull String replacePlaceholders(@Nonnull org.bukkit.entity.Player player, @Nonnull String input)
      Replaces an input with nChat placeholders.
      Parameters:
      player - the desired player
      input - the content to be replaced
      Returns:
      content with processed placeholders
      Throws:
      IllegalStateException - if the API is not yet fully loaded
      Since:
      API v1
    • getPublicChannels

      @Nonnull Set<PublicChannel> getPublicChannels()
      Lists all registered public channels.
      Throws:
      IllegalStateException - if the API is not yet fully loaded
      Since:
      API v1
    • getPrivateChannels

      @Nonnull Set<PrivateChannel> getPrivateChannels()
      Lists all registered private channels.
      Throws:
      IllegalStateException - if the API is not yet fully loaded
      Since:
      API v1
    • getChannelByName

      Optional<PublicChannel> getChannelByName(@Nonnull String name)
      Gets a public channel registered by name.
      Parameters:
      name - the name of the channel
      Throws:
      IllegalStateException - if the API is not yet fully loaded
      Since:
      API v1
    • getPrivateChannelByName

      Optional<PrivateChannel> getPrivateChannelByName(@Nonnull String name, boolean isProxy)
      Gets a private channel registered by name.
      Parameters:
      name - the name of the channel
      isProxy - true if the channel is a proxy
      Throws:
      IllegalStateException - if the API is not yet fully loaded
      Since:
      API v1
    • getChannelByCommand

      Optional<PublicChannel> getChannelByCommand(@Nonnull String command)
      Gets a public channel registered by command.
      Parameters:
      command - command of the channel
      Throws:
      IllegalStateException - if the API is not yet fully loaded
      Since:
      API v1
    • getChannelByNameAndCommand

      Optional<PublicChannel> getChannelByNameAndCommand(@Nonnull String input)
      Gets a public channel registered by name and command.
      Parameters:
      input - the name or command of the channel
      Throws:
      IllegalStateException - if the API is not yet fully loaded
      Since:
      API v1
    • hasChannelByName

      default boolean hasChannelByName(@Nonnull String name)
      Check if a public channel exists by name.
      Parameters:
      name - the name of the channel
      Throws:
      IllegalStateException - if the API is not yet fully loaded
      Since:
      API v1
    • hasPrivateChannelByName

      default boolean hasPrivateChannelByName(@Nonnull String name, boolean isProxy)
      Check if a private channel exists by name.
      Parameters:
      name - the name of the channel
      isProxy - true if the channel is a proxy
      Throws:
      IllegalStateException - if the API is not yet fully loaded
      Since:
      API v1
    • hasChannelByCommand

      default boolean hasChannelByCommand(@Nonnull String command)
      Check if a public channel exists by command.
      Parameters:
      command - command of the channel
      Throws:
      IllegalStateException - if the API is not yet fully loaded
      Since:
      API v1
    • hasChannelByNameAndCommand

      default boolean hasChannelByNameAndCommand(@Nonnull String input)
      Check if a public channel exists by name or command.
      Parameters:
      input - the name or command of the channel
      Throws:
      IllegalStateException - if the API is not yet fully loaded
      Since:
      API v1
    • handlePublicMessage

      default void handlePublicMessage(@Nonnull org.bukkit.entity.Player sender, @Nonnull String message, @Nonnull PublicChannel publicChannel, @Nullable Consumer<PublicMessageEvent> callback)
      Sends a message on nChat.
      Parameters:
      sender - the player used to send it
      message - the message to be sent
      publicChannel - the channel to be used
      callback - the callback of the handled event
      Throws:
      IllegalStateException - if the API is not yet fully loaded
      Since:
      API v1
    • handlePublicMessage

      void handlePublicMessage(@Nonnull org.bukkit.entity.Player sender, @Nonnull String message, @Nonnull PublicChannel publicChannel, boolean force, @Nullable Consumer<PublicMessageEvent> callback)
      Sends a message on nChat.
      Parameters:
      sender - the player used to send it
      message - the message to be sent
      publicChannel - the channel to be used
      force - if true, forces the message to be sent (ignores permissions, cost and delay).
      callback - the callback of the handled event
      Throws:
      IllegalStateException - if the API is not yet fully loaded
      Since:
      API v1
    • handleVirtualMessage

      default void handleVirtualMessage(@Nonnull String format, @Nonnull PublicChannel publicChannel, @Nullable Consumer<VirtualMessageEvent> callback)
      Sends a virtual message on nChat.
      Parameters:
      format - format of the message sent
      publicChannel - the channel to be used
      callback - the callback of the handled event
      Throws:
      IllegalStateException - if the API is not yet fully loaded
      Since:
      API v1
    • handleVirtualMessage

      default void handleVirtualMessage(@Nonnull String format, @Nonnull PublicChannel publicChannel, boolean highlight, @Nullable Consumer<VirtualMessageEvent> callback)
      Sends a virtual message on nChat.
      Parameters:
      format - format of the message sent
      publicChannel - the channel to be used
      highlight - if true, highlights the message
      callback - the callback of the handled event
      Throws:
      IllegalStateException - if the API is not yet fully loaded
      Since:
      API v1
    • handleVirtualMessage

      default void handleVirtualMessage(@Nullable String sender, @Nonnull String format, @Nonnull PublicChannel publicChannel, @Nullable Consumer<VirtualMessageEvent> callback)
      Sends a virtual message on nChat.
      Parameters:
      sender - the player that will send the message (optional)
      format - format of the message to be sent
      publicChannel - the channel to be used
      callback - the callback of the handled event
      Throws:
      IllegalStateException - if the API is not yet fully loaded
      Since:
      API v1
    • handleVirtualMessage

      void handleVirtualMessage(@Nullable String sender, @Nonnull String format, @Nonnull PublicChannel publicChannel, boolean highlight, @Nullable Consumer<VirtualMessageEvent> callback)
      Sends a virtual message on nChat.
      Parameters:
      sender - the player that will send the message (optional)
      format - format of the message to be sent
      publicChannel - the channel to be used
      highlight - if true, highlights the message
      callback - the callback of the handled event
      Throws:
      IllegalStateException - if the API is not yet fully loaded
      Since:
      API v1
    • reloadConfig

      void reloadConfig()
      Reloads the nChat config.
      Throws:
      IllegalStateException - if the API is not yet fully loaded
      Since:
      API v1
    • reloadChannels

      void reloadChannels()
      Reloads nChat's public and private channels.
      Throws:
      IllegalStateException - if the API is not yet fully loaded
      Since:
      API v1
    • createChannel

      boolean createChannel(@Nonnull Channel channel)
      Creates a new channel
      Parameters:
      channel - the channel to be created
      Returns:
      true if the channel was created
      Throws:
      IllegalStateException - if the API is not yet fully loaded
      Since:
      API v1
    • reloadChannel

      boolean reloadChannel(@Nonnull Channel channel)
      Reloads a canal.
      Parameters:
      channel - the channel to be reloaded
      Returns:
      true if the channel exists
      Since:
      API v1
    • saveChannel

      boolean saveChannel(@Nonnull Channel channel)
      Saves a canal.
      Parameters:
      channel - the channel to be saved
      Returns:
      true if the channel already exists or was successfully created
      Since:
      API v1
    • deleteChannel

      boolean deleteChannel(@Nonnull Channel channel)
      Deletes a channel.
      Parameters:
      channel - the channel to be deleted
      Returns:
      true if the channel existed
      Since:
      API v1
    • internal

      Returns the nChat internal api.