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.JavaPlugin
Represents a plugin using Annoying API
-
Field Summary
FieldsModifier and TypeFieldDescriptionfinal @NotNull CooldownManagerTheCooldownManagerfor the pluginfinal @NotNull Map<Class<? extends org.bukkit.event.Event>, AnnoyingListener> Custom events/listeners for the API@Nullable DataManagerTheDataManagerfor the pluginstatic booleanWhether the server is running on FoliaChatColoraliases for the plugin from the messages file (MessagesOptions.MessageKeys.globalPlaceholders)final @NotNull AnnoyingLibraryManagerTheAnnoyingLibraryManagerfor the plugin to managelibrariesstatic @NotNull Logger@Nullable AnnoyingResourceTheAnnoyingResourcethat contains the plugin's messagesstatic final @NotNull xyz.srnyx.javautilities.objects.SemanticVersionThe Minecraft version the server is runningfinal @NotNull AnnoyingOptionsThe API options for the pluginbooleanWhether PlaceholderAPI is installedfinal @NotNull Set<Registrable> Set of registeredRegistrables by the pluginfinal @NotNull AnnoyingSchedulerTheAnnoyingSchedulerfor the plugin, used to run scheduled tasks in place ofBukkitSchedulerfinal @NotNull SelectorManagerTheSelectorManagerfor the plugin@Nullable AnnoyingStatsWrapper for bStats -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoiddisable()Called when the plugin is disabledvoidRunsPluginManager.disablePlugin(Plugin)withthisas the plugin
Do not override this method! Overridedisable()insteadvoidenable()Called after dependency checks, start-up messages, and command/listener registration@NotNull StringGets the package path for relocated libraries@NotNull StringgetMessagesString(@NotNull String key) Gets a string frommessageswith the specified key@NotNull net.byteflux.libby.relocation.RelocationgetRelocation(@NotNull String from) Gets aRelocationfor the specified package@NotNull net.byteflux.libby.relocation.RelocationgetRelocation(@NotNull String from, @NotNull 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()voidLoads the messages.yml file tomessagesandglobalPlaceholdersstatic voidstatic voidstatic voidLogs a message with the specified level and throwable to the consolefinal voidCalled when the plugin is disabledfinal voidonEnable()Called when the plugin is enabled.final voidonLoad()Called after a plugin is loaded but before it has been enabled.@NotNull StringparsePapiPlaceholders(@Nullable org.bukkit.OfflinePlayer player, @Nullable String message) Parses all PlaceholderAPI placeholders in a messagevoidreload()Called when the plugin is reloadedvoidReloads the plugin (messages, etc...).static @NotNull StringreplaceBrackets(@NotNull String string) Replaces all instances of{}in a string with.
Used for replacing brackets in package namesvoidUnregisters allRegistrables inregisteredClassesMethods 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, toStringMethods inherited from class org.bukkit.plugin.PluginBase
equals, getName, hashCode
-
Field Details
-
LOGGER
-
MINECRAFT_VERSION
@NotNull public static final @NotNull xyz.srnyx.javautilities.objects.SemanticVersion MINECRAFT_VERSIONThe Minecraft version the server is running -
FOLIA
public static boolean FOLIAWhether the server is running on Folia -
options
The API options for the plugin -
libraryManager
TheAnnoyingLibraryManagerfor the plugin to managelibraries -
stats
Wrapper for bStats -
messages
TheAnnoyingResourcethat contains the plugin's messages -
globalPlaceholders
ChatColoraliases for the plugin from the messages file (MessagesOptions.MessageKeys.globalPlaceholders)- See Also:
-
dataManager
TheDataManagerfor the plugin -
registeredClasses
Set of registeredRegistrables by the plugin -
customEvents
@NotNull public final @NotNull Map<Class<? extends org.bukkit.event.Event>,AnnoyingListener> customEventsCustom events/listeners for the API -
selectorManager
TheSelectorManagerfor the plugin -
cooldownManager
TheCooldownManagerfor the plugin -
scheduler
TheAnnoyingSchedulerfor the plugin, used to run scheduled tasks in place ofBukkitScheduler -
papiInstalled
public boolean papiInstalledWhether PlaceholderAPI is installed
-
-
Constructor Details
-
AnnoyingPlugin
public AnnoyingPlugin()Constructs a newAnnoyingPlugininstance
-
-
Method Details
-
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:
-
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:
-
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:
-
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()RunsPluginManager.disablePlugin(Plugin)withthisas the plugin
Do not override this method! Overridedisable()instead- See Also:
-
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:
-
loadMessages
public void loadMessages()Loads the messages.yml file tomessagesandglobalPlaceholders -
getMessagesString
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 String parsePapiPlaceholders(@Nullable @Nullable org.bukkit.OfflinePlayer player, @Nullable @Nullable 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:
-
loadDataManger
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)
-
getRelocation
@NotNull public @NotNull net.byteflux.libby.relocation.Relocation getRelocation(@NotNull @NotNull String from, @NotNull @NotNull 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 String from) Gets aRelocationfor the specified package- Parameters:
from- the package to relocate- Returns:
- the relocation
-
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. Ifnull,Level.INFOwill be usedmessage- the message to logthrowable- the throwable to log
-
log
- Parameters:
level- the level of the message. Ifnull,Level.INFOwill be usedmessage- the message to log
-
log
- Parameters:
message- the message to log
-
replaceBrackets
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
-