Class 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
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      @NotNull java.util.Optional<org.bukkit.scheduler.BukkitTask> attemptAsync​(@NotNull java.lang.Runnable runnable)
      Attempt to run a task asynchronously if the plugin is enabled, otherwise run it synchronously
      void checkUpdate()
      void disable()
      Called when the plugin is disabled
      void disablePlugin()
      Runs PluginManager.disablePlugin(Plugin) with this as the plugin
      Do not override this method! Override disable() instead
      void enable()
      Called after dependency checks, start-up messages, and command/listener registration
      @NotNull java.lang.String getLibsPackage()
      Gets the package path for relocated libraries
      @NotNull java.lang.String getMessagesString​(@NotNull java.lang.String key)
      Gets a string from messages with the specified key
      @NotNull net.byteflux.libby.relocation.Relocation getRelocation​(@NotNull java.lang.String from)
      Gets a Relocation for the specified package
      @NotNull net.byteflux.libby.relocation.Relocation getRelocation​(@NotNull java.lang.String from, @NotNull java.lang.String name)
      Gets a Relocation for the specified package
      void load()
      Called when the plugin is loaded
      void loadDataManger​(@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()
      void loadMessages()
      Loads the messages.yml file to messages and globalPlaceholders
      static void log​(@Nullable java.lang.Object message)
      Calls log(Level, Object, Throwable) with null as the level and throwable
      static void log​(@Nullable java.util.logging.Level level, @Nullable java.lang.Object message)
      Calls log(Level, Object, Throwable) with null as the throwable
      static void log​(@Nullable java.util.logging.Level level, @Nullable java.lang.Object message, @Nullable java.lang.Throwable throwable)
      Logs a message with the specified level and throwable to the console
      void onDisable()
      Called when the plugin is disabled
      void onEnable()
      Called when the plugin is enabled.
      void onLoad()
      Called after a plugin is loaded but before it has been enabled.
      @NotNull java.lang.String parsePapiPlaceholders​(@Nullable org.bukkit.OfflinePlayer player, @Nullable java.lang.String message)
      Parses all PlaceholderAPI placeholders in a message
      void reload()
      Called when the plugin is reloaded
      void reloadPlugin()
      Reloads the plugin (messages, etc...).
      static @NotNull java.lang.String replaceBrackets​(@NotNull java.lang.String string)
      Replaces all instances of {} in a string with .
      Used for replacing brackets in package names
      void unregisterClasses()
      Unregisters all Registrables in registeredClasses
      • Methods inherited from class org.bukkit.plugin.java.JavaPlugin

        getClassLoader, getCommand, getConfig, getDatabase, getDatabaseClasses, getDataFolder, getDefaultWorldGenerator, getDescription, getFile, getLogger, getPlugin, getPluginLoader, getProvidingPlugin, getResource, getServer, getTextResource, initialize, installDDL, isEnabled, isInitialized, isNaggable, onCommand, onTabComplete, reloadConfig, removeDDL, saveConfig, saveDefaultConfig, saveResource, setEnabled, setNaggable, toString
      • Methods inherited from class org.bukkit.plugin.PluginBase

        equals, getName, hashCode
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • LOGGER

        @NotNull
        public static @NotNull java.util.logging.Logger LOGGER
        The Logger for the plugin
        Uses temporary initialization until the plugin is constructed (loaded)
      • MINECRAFT_VERSION

        @NotNull
        public static final @NotNull xyz.srnyx.javautilities.objects.SemanticVersion MINECRAFT_VERSION
        The Minecraft version the server is running
      • options

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

        @Nullable
        public @Nullable AnnoyingStats stats
        Wrapper for bStats
      • registeredClasses

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

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

        public boolean papiInstalled
        Whether PlaceholderAPI is installed
    • Constructor Detail

      • AnnoyingPlugin

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

      • 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:
        load()
      • 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:
        enable()
      • 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:
        disable()
      • load

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

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

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

        public void disablePlugin()
        Runs PluginManager.disablePlugin(Plugin) with this as the plugin
        Do not override this method! Override disable() instead
        See Also:
        disable()
      • 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:
        reload()
      • getMessagesString

        @NotNull
        public @NotNull java.lang.String getMessagesString​(@NotNull
                                                           @NotNull java.lang.String key)
        Gets a string from messages with the specified key
        Parameters:
        key - the key of the string
        Returns:
        the string, or the key if messages is null or the string is not found
      • parsePapiPlaceholders

        @NotNull
        public @NotNull java.lang.String parsePapiPlaceholders​(@Nullable
                                                               @Nullable org.bukkit.OfflinePlayer player,
                                                               @Nullable
                                                               @Nullable java.lang.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
      • 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)
      • attemptAsync

        @NotNull
        public @NotNull java.util.Optional<org.bukkit.scheduler.BukkitTask> attemptAsync​(@NotNull
                                                                                         @NotNull java.lang.Runnable runnable)
        Attempt to run a task asynchronously if the plugin is enabled, otherwise run it synchronously
        Parameters:
        runnable - the task to run
        Returns:
        the BukkitTask if the task was run asynchronously, otherwise Optional.empty()
      • getRelocation

        @NotNull
        public @NotNull net.byteflux.libby.relocation.Relocation getRelocation​(@NotNull
                                                                               @NotNull java.lang.String from,
                                                                               @NotNull
                                                                               @NotNull java.lang.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 java.lang.String from)
        Gets a Relocation for the specified package
        Parameters:
        from - the package to relocate
        Returns:
        the relocation
      • getLibsPackage

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

        public static void log​(@Nullable
                               @Nullable java.util.logging.Level level,
                               @Nullable
                               @Nullable java.lang.Object message,
                               @Nullable
                               @Nullable java.lang.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 java.util.logging.Level level,
                               @Nullable
                               @Nullable java.lang.Object message)
        Calls log(Level, Object, Throwable) with null as the throwable
        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 java.lang.Object message)
        Calls log(Level, Object, Throwable) with null as the level and throwable
        Parameters:
        message - the message to log
      • replaceBrackets

        @NotNull
        public static @NotNull java.lang.String replaceBrackets​(@NotNull
                                                                @NotNull java.lang.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