Class ChatPlugin

java.lang.Object
me.remigio07.chatplugin.api.ChatPlugin

public abstract class ChatPlugin extends Object
ChatPlugin's main class's abstraction.
  • Field Details

    • VERSION

      public static final String VERSION
      String containing the plugin's current version.

      This string follows Semantic Versioning.

      Content: 🤷

  • Constructor Details

    • ChatPlugin

      public ChatPlugin()
  • Method Details

    • getManagers

      public ChatPluginManagers getManagers()
      Gets the managers' manager. Yeah...
      Returns:
      Managers' manager
    • getLogger

      public Object getLogger()
      Gets the plugin's logger.

      There are two loggers supported:

      Returns:
      Plugin's logger
      See Also:
    • getDataFolder

      public File getDataFolder()
      Gets the plugin's data folder in the plugins (Bukkit/BungeeCord/Velocity) or mods (Sponge) folder.
      Returns:
      Plugin's data folder
    • getStartupTime

      public int getStartupTime()
      Gets the time elapsed during the plugin's startup, in milliseconds.
      Returns:
      Startup's time, in milliseconds
    • getLastReloadTime

      public int getLastReloadTime()
      Gets the time elapsed during the plugin's last reload, in milliseconds.

      Will return -1 if no reloads have been performed yet.

      Returns:
      Last reload's time, in milliseconds
    • getInstance

      public static ChatPlugin getInstance()
      Gets the main instance of the plugin.

      You may need instances of the bootstrappers instead: check the following methods, too.

      Returns:
      Main instance
      See Also:
    • getState

      public static ChatPluginState getState()
      Gets the plugin's state.
      Returns:
      Plugin's state
    • reload

      public abstract int reload()
      Reloads ChatPlugin. Totally.

      If the reload fails the plugin will be safely disabled, enter recovery mode if possible and send an error message to the console.

      Returns:
      Time elapsed in milliseconds or 0 if not loaded or -1 if failed
      See Also:
    • unload

      @Deprecated public abstract int unload()
      Deprecated.
      Internal use only. You should never need to manually unload ChatPlugin.
      Unloads ChatPlugin.

      If the unload fails the plugin will be safely disabled, enter recovery mode if possible and send an error message to the console.

      Returns:
      Time elapsed in milliseconds or 0 if not loaded or -1 if failed
      See Also:
    • runConsoleCommand

      public abstract void runConsoleCommand(String command, boolean forceSync)
      Runs a command from the console synchronously.

      It will run on the next server tick if forceSync. Otherwise, make sure the call comes from the server's main thread, unless Environment.isProxy(), where everything is asynchronous.

      Parameters:
      command - Command to run
      forceSync - Whether to force synchronization
    • sendConsoleMessage

      public abstract void sendConsoleMessage(String message, boolean log)
      Sends a message to the console.
      Parameters:
      message - Message to send
      log - Whether to LogManager.writeToFile(String) the message
    • printStartMessage

      public abstract void printStartMessage()
      Prints the beautiful start message.
    • isOnlineMode

      public abstract boolean isOnlineMode()
      Checks if the plugin is running on online mode.
      Returns:
      Whether online mode is enabled
      Throws:
      IllegalStateException - If !Environment.isProxy() and ChatPlugin has not finished loading yet
    • isPremium

      public abstract boolean isPremium()
      Checks if a premium copy of the plugin is running.
      Returns:
      Whether the plugin is premium