Package xyz.srnyx.annoyingapi
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.JavaPluginRepresents a plugin using Annoying API
-
-
Field Summary
Fields Modifier and Type Field Description @NotNull CooldownManagercooldownManagerTheCooldownManagerfor the plugin@NotNull java.util.Map<java.lang.Class<? extends org.bukkit.event.Event>,AnnoyingListener>customEventsCustom events/listeners for the API@Nullable DataManagerdataManagerTheDataManagerfor the plugin@NotNull java.util.Map<java.lang.String,java.lang.String>globalPlaceholdersChatColoraliases for the plugin from the messages file (MessagesOptions.MessageKeys.globalPlaceholders)@NotNull AnnoyingLibraryManagerlibraryManagerTheAnnoyingLibraryManagerfor the plugin to managelibrariesstatic @NotNull java.util.logging.LoggerLOGGER@Nullable AnnoyingResourcemessagesTheAnnoyingResourcethat contains the plugin's messagesstatic @NotNull xyz.srnyx.javautilities.objects.SemanticVersionMINECRAFT_VERSIONThe Minecraft version the server is running@NotNull AnnoyingOptionsoptionsThe API options for the pluginbooleanpapiInstalledWhether PlaceholderAPI is installed@NotNull java.util.Set<Registrable>registeredClassesSet of registeredRegistrables by the plugin@Nullable AnnoyingStatsstatsWrapper for bStats
-
Constructor Summary
Constructors Constructor Description AnnoyingPlugin()Constructs a newAnnoyingPlugininstance
-
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 synchronouslyvoidcheckUpdate()voiddisable()Called when the plugin is disabledvoiddisablePlugin()RunsPluginManager.disablePlugin(Plugin)withthisas the plugin
Do not override this method! Overridedisable()insteadvoidenable()Called after dependency checks, start-up messages, and command/listener registration@NotNull java.lang.StringgetLibsPackage()Gets the package path for relocated libraries@NotNull java.lang.StringgetMessagesString(@NotNull java.lang.String key)Gets a string frommessageswith the specified key@NotNull net.byteflux.libby.relocation.RelocationgetRelocation(@NotNull java.lang.String from)Gets aRelocationfor the specified package@NotNull net.byteflux.libby.relocation.RelocationgetRelocation(@NotNull java.lang.String from, @NotNull java.lang.String name)Gets aRelocationfor the specified packagevoidload()Called when the plugin is loadedvoidloadDataManger(@Nullable StorageConfig storageConfig, boolean saveCache)Attempts to load thedataManager, catching any exceptions and logging them
Ifstorage-new.ymlexists, it will attempt to migrate the data fromstorage.ymltostorage-new.ymlusingDataManager.attemptDatabaseMigration()voidloadMessages()Loads the messages.yml file tomessagesandglobalPlaceholdersstatic voidlog(@Nullable java.lang.Object message)static voidlog(@Nullable java.util.logging.Level level, @Nullable java.lang.Object message)static voidlog(@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 consolevoidonDisable()Called when the plugin is disabledvoidonEnable()Called when the plugin is enabled.voidonLoad()Called after a plugin is loaded but before it has been enabled.@NotNull java.lang.StringparsePapiPlaceholders(@Nullable org.bukkit.OfflinePlayer player, @Nullable java.lang.String message)Parses all PlaceholderAPI placeholders in a messagevoidreload()Called when the plugin is reloadedvoidreloadPlugin()Reloads the plugin (messages, etc...).static @NotNull java.lang.StringreplaceBrackets(@NotNull java.lang.String string)Replaces all instances of{}in a string with.
Used for replacing brackets in package namesvoidunregisterClasses()Unregisters allRegistrables inregisteredClasses-
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
-
-
-
-
Field Detail
-
LOGGER
@NotNull public static @NotNull java.util.logging.Logger LOGGER
-
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
-
libraryManager
@NotNull public final @NotNull AnnoyingLibraryManager libraryManager
TheAnnoyingLibraryManagerfor the plugin to managelibraries
-
stats
@Nullable public @Nullable AnnoyingStats stats
Wrapper for bStats
-
messages
@Nullable public @Nullable AnnoyingResource messages
TheAnnoyingResourcethat contains the plugin's messages
-
globalPlaceholders
@NotNull public final @NotNull java.util.Map<java.lang.String,java.lang.String> globalPlaceholders
ChatColoraliases for the plugin from the messages file (MessagesOptions.MessageKeys.globalPlaceholders)
-
dataManager
@Nullable public @Nullable DataManager dataManager
TheDataManagerfor the plugin
-
registeredClasses
@NotNull public final @NotNull java.util.Set<Registrable> registeredClasses
Set of registeredRegistrables 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
-
cooldownManager
@NotNull public final @NotNull CooldownManager cooldownManager
TheCooldownManagerfor the plugin
-
papiInstalled
public boolean papiInstalled
Whether PlaceholderAPI is installed
-
-
Constructor Detail
-
AnnoyingPlugin
public AnnoyingPlugin()
Constructs a newAnnoyingPlugininstance
-
-
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:
onLoadin interfaceorg.bukkit.plugin.Plugin- Overrides:
onLoadin classorg.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:
onEnablein interfaceorg.bukkit.plugin.Plugin- Overrides:
onEnablein classorg.bukkit.plugin.java.JavaPlugin- See Also:
enable()
-
onDisable
public final void onDisable()
Called when the plugin is disabledDo not try to override this method! Override
disable()instead- Specified by:
onDisablein interfaceorg.bukkit.plugin.Plugin- Overrides:
onDisablein classorg.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()
-
disable
public void disable()
Called when the plugin is disabled- See Also:
onDisable(),disablePlugin()
-
reload
public void reload()
Called when the plugin is reloaded- See Also:
reloadPlugin()
-
disablePlugin
public void disablePlugin()
RunsPluginManager.disablePlugin(Plugin)withthisas the plugin
Do not override this method! Overridedisable()instead- See Also:
disable()
-
reloadPlugin
public void reloadPlugin()
Reloads the plugin (messages, etc...). This will not triggeronLoad()oronEnable()This is not run automatically (such as
onEnable()andonDisable()), it is to be used manually by the plugin itself (ex: in a/reloadcommand)Do not override this method! Override
reload()instead- See Also:
reload()
-
loadMessages
public void loadMessages()
Loads the messages.yml file tomessagesandglobalPlaceholders
-
getMessagesString
@NotNull public @NotNull java.lang.String getMessagesString(@NotNull @NotNull java.lang.String key)Gets a string frommessageswith the specified key- Parameters:
key- the key of the string- Returns:
- the string, or the
keyifmessagesisnullor 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- theOfflinePlayerto parse the placeholders for (ornullif none)message- the message to parse- Returns:
- the parsed message
-
unregisterClasses
public void unregisterClasses()
Unregisters allRegistrables inregisteredClasses
-
checkUpdate
public void checkUpdate()
- See Also:
AnnoyingUpdate
-
loadDataManger
public void loadDataManger(@Nullable @Nullable StorageConfig storageConfig, boolean saveCache)Attempts to load thedataManager, catching any exceptions and logging them
Ifstorage-new.ymlexists, it will attempt to migrate the data fromstorage.ymltostorage-new.ymlusingDataManager.attemptDatabaseMigration()- Parameters:
storageConfig- theStorageConfigto load the data manager with. Ifnull,storage.ymlwill be usedsaveCache- whether to save the cache before loading the data manager (data may be lost iffalse)
-
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
BukkitTaskif the task was run asynchronously, otherwiseOptional.empty()
-
getRelocation
@NotNull public @NotNull net.byteflux.libby.relocation.Relocation getRelocation(@NotNull @NotNull java.lang.String from, @NotNull @NotNull java.lang.String name)Gets aRelocationfor the specified package- Parameters:
from- the package to relocatename- 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 aRelocationfor 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. Ifnull,Level.INFOwill be usedmessage- the message to logthrowable- the throwable to log
-
log
public static void log(@Nullable @Nullable java.util.logging.Level level, @Nullable @Nullable java.lang.Object message)- Parameters:
level- the level of the message. Ifnull,Level.INFOwill be usedmessage- the message to log
-
log
public static void log(@Nullable @Nullable java.lang.Object message)- 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
-
-