Class AnnoyingPlugin

java.lang.Object
org.bukkit.plugin.PluginBase
org.bukkit.plugin.java.JavaPlugin
xyz.srnyx.annoyingapi.AnnoyingPlugin
All Implemented Interfaces:
org.bukkit.command.CommandExecutor, org.bukkit.command.TabCompleter, org.bukkit.command.TabExecutor, org.bukkit.plugin.Plugin

public class AnnoyingPlugin extends org.bukkit.plugin.java.JavaPlugin
Represents a plugin using Annoying API
  • Field Details

    • LOGGER

      @NotNull public static @NotNull Logger LOGGER
      Uses temporary initialization until the plugin is constructed (loaded)
    • SERVER_SOFTWARE

      @NotNull public static final @NotNull ServerSoftware SERVER_SOFTWARE
    • MINECRAFT_VERSION

      @NotNull public static final @NotNull xyz.srnyx.javautilities.objects.SemanticVersion MINECRAFT_VERSION
    • options

      @NotNull public final @NotNull AnnoyingOptions options
      The API options for the plugin
    • libraryManager

      @Nullable public final @Nullable AnnoyingLibraryManager libraryManager
      The AnnoyingLibraryManager for the plugin to manage libraries
      Only null in unit tests
    • configLoader

      @NotNull public final @NotNull ConfigLoader configLoader
      Loader for OkaeriConfig configs
    • dataManager

      @Nullable public @Nullable DataManager dataManager
      The DataManager for the plugin
    • registeredClasses

      @NotNull public final @NotNull Set<Registrable> registeredClasses
      Set of registered Registrables by the plugin
    • customEvents

      @NotNull public final @NotNull Map<Class<? extends org.bukkit.event.Event>,AnnoyingListener> customEvents
      Custom events/listeners for the API
    • selectorManager

      @NotNull public final @NotNull SelectorManager selectorManager
      The SelectorManager for the plugin
    • cooldownManager

      @NotNull public final @NotNull CooldownManager cooldownManager
      The CooldownManager for the plugin
    • scheduler

      @NotNull public final @NotNull AnnoyingScheduler scheduler
      The AnnoyingScheduler for the plugin, used to run scheduled tasks in place of BukkitScheduler
    • updateChecker

      @Nullable public @Nullable UpdateChecker updateChecker
    • papiInstalled

      public boolean papiInstalled
      Whether PlaceholderAPI is installed
  • Constructor Details

    • AnnoyingPlugin

      public AnnoyingPlugin()
      Constructs a new AnnoyingPlugin instance
  • Method Details

    • createLibraryManager

      @Nullable protected @Nullable AnnoyingLibraryManager createLibraryManager()
    • onLoad

      public final void onLoad()
      Called after a plugin is loaded but before it has been enabled. When multiple plugins are loaded, the onLoad() for all plugins is called before any onEnable() is called.

      Do not try to override this method! Override load() instead

      Specified by:
      onLoad in interface org.bukkit.plugin.Plugin
      Overrides:
      onLoad in class org.bukkit.plugin.java.JavaPlugin
      See Also:
    • onEnable

      public final void onEnable()
      Called when the plugin is enabled.

      Do not try to override this method! Override enable() instead

      Specified by:
      onEnable in interface org.bukkit.plugin.Plugin
      Overrides:
      onEnable in class org.bukkit.plugin.java.JavaPlugin
      See Also:
    • onDisable

      public final void onDisable()
      Called when the plugin is disabled

      Do not try to override this method! Override disable() instead

      Specified by:
      onDisable in interface org.bukkit.plugin.Plugin
      Overrides:
      onDisable in class org.bukkit.plugin.java.JavaPlugin
      See Also:
    • load

      public void load()
      Called when the plugin is loaded
      See Also:
    • enable

      public void enable()
      Called after dependency checks, start-up messages, and command/listener registration
      See Also:
    • disable

      public void disable()
      Called when the plugin is disabled
      See Also:
    • reload

      public void reload()
      Called when the plugin is reloaded
      See Also:
    • disablePlugin

      public void disablePlugin()
      Runs PluginManager.disablePlugin(Plugin) with this as the plugin
      Do not override this method! Override disable() instead
      See Also:
    • reloadPlugin

      public void reloadPlugin()
      Reloads the plugin (messages, etc...). This will not trigger onLoad() or onEnable()

      This is not run automatically (such as onEnable() and onDisable()), it is to be used manually by the plugin itself (ex: in a /reload command)

      Do not override this method! Override reload() instead

      See Also:
    • getRegistrable

      @Nullable public <T extends Registrable> T getRegistrable(@NotNull @NotNull Class<T> clazz)
      Get a Registrable by its super-class or exact class
      Type Parameters:
      T - The type of the Registrable
      Parameters:
      clazz - The class of the Registrable to get
      Returns:
      The Registrable if it exists, or null if it doesn't
    • getRegistrableExact

      @Nullable public <T extends Registrable> T getRegistrableExact(@NotNull @NotNull Class<T> clazz)
      Get a Registrable by its exact class
      Type Parameters:
      T - The type of the Registrable
      Parameters:
      clazz - The exact class of the Registrable to get
      Returns:
      The Registrable if it exists, or null if it doesn't
    • unregisterClasses

      public void unregisterClasses()
      Unregisters all Registrables in registeredClasses
    • getMessages

      @NotNull public @NotNull MessagesProvider getMessages()
    • getAnnoyingMessages

      @NotNull public final @NotNull AnnoyingMessages getAnnoyingMessages()
      Not overrideable as it would cause a NoClassDefFoundError for OkaeriConfig in consumers!
    • parsePapiPlaceholders

      @NotNull public @NotNull String parsePapiPlaceholders(@Nullable @Nullable org.bukkit.OfflinePlayer player, @Nullable @Nullable String message)
      Parses all PlaceholderAPI placeholders in a message
      Parameters:
      player - the OfflinePlayer to parse the placeholders for (or null if none)
      message - the message to parse
      Returns:
      the parsed message
    • newStorageConfig

      @Nullable public @Nullable StorageConfig newStorageConfig(@NotNull @NotNull String fileName)
    • newStorageConfig

      @Nullable public @Nullable StorageConfig newStorageConfig()
    • loadDataManger

      public void loadDataManger(@Nullable @Nullable StorageConfig storageConfig, boolean saveCache)
      Attempts to load the dataManager, catching any exceptions and logging them
      If storage-new.yml exists, it will attempt to migrate the data from storage.yml to storage-new.yml using DataManager.attemptDatabaseMigration()
      Parameters:
      storageConfig - the StorageConfig to load the data manager with. If null, storage.yml will be used
      saveCache - whether to save the cache before loading the data manager (data may be lost if false)
    • getRelocation

      @NotNull public @NotNull net.byteflux.libby.relocation.Relocation getRelocation(@NotNull @NotNull String from, @NotNull @NotNull String name)
      Gets a Relocation for the specified package
      Parameters:
      from - the package to relocate
      name - the name of the module being relocated (getLibsPackage() + name)
      Returns:
      the relocation
    • getRelocation

      @NotNull public @NotNull net.byteflux.libby.relocation.Relocation getRelocation(@NotNull @NotNull String from)
      Gets a Relocation for the specified package
      Parameters:
      from - the package to relocate
      Returns:
      the relocation
    • getLibsPackage

      @NotNull public @NotNull String getLibsPackage()
      Gets the package path for relocated libraries
      Returns:
      the path
    • log

      public static void log(@Nullable @Nullable Level level, @Nullable @Nullable Object message, @Nullable @Nullable Throwable throwable)
      Logs a message with the specified level and throwable to the console
      Parameters:
      level - the level of the message. If null, Level.INFO will be used
      message - the message to log
      throwable - the throwable to log
    • log

      public static void log(@Nullable @Nullable Level level, @Nullable @Nullable Object message)
      Parameters:
      level - the level of the message. If null, Level.INFO will be used
      message - the message to log
    • log

      public static void log(@Nullable @Nullable Object message)
      Calls log(Level, Object, Throwable) with null as the level and throwable
      Parameters:
      message - the message to log
    • logErrorTrack

      public void logErrorTrack(@Nullable @Nullable Level level, @Nullable @Nullable Object message, @Nullable @Nullable Throwable throwable)
    • logErrorTrack

      public void logErrorTrack(@Nullable @Nullable Level level, @Nullable @Nullable Object message)
    • logErrorTrack

      public void logErrorTrack(@Nullable @Nullable Object message)
    • errorTrack

      public void errorTrack(@Nullable @Nullable Object message, @Nullable @Nullable Throwable throwable)
    • errorTrack

      public void errorTrack(@Nullable @Nullable Object message)
    • errorTrack

      public void errorTrack(@Nullable @Nullable Throwable throwable)
    • deleteOldFile

      public void deleteOldFile(@NotNull @NotNull Path path)
    • replaceBrackets

      @NotNull public static @NotNull String replaceBrackets(@NotNull @NotNull String string)
      Replaces all instances of {} in a string with .
      Used for replacing brackets in package names
      Parameters:
      string - the string to replace brackets in
      Returns:
      the string with brackets replaced