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 ConfigLoaderLoader for OkaeriConfig configsfinal @NotNull CooldownManagerTheCooldownManagerfor the pluginfinal @NotNull Map<Class<? extends org.bukkit.event.Event>, AnnoyingListener> Custom events/listeners for the API@Nullable DataManagerTheDataManagerfor the pluginfinal @Nullable AnnoyingLibraryManagerstatic @NotNull LoggerUses temporary initialization until thepluginis constructed (loaded)static final @NotNull xyz.srnyx.javautilities.objects.SemanticVersionfinal @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 pluginstatic final @NotNull ServerSoftware@Nullable UpdateChecker -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected @Nullable AnnoyingLibraryManagervoiddeleteOldFile(@NotNull Path path) voiddisable()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 registrationvoiderrorTrack(@Nullable Object message) voiderrorTrack(@Nullable Object message, @Nullable Throwable throwable) voiderrorTrack(@Nullable Throwable throwable) final @NotNull AnnoyingMessagesNot overrideable as it would cause aNoClassDefFoundErrorforOkaeriConfigin consumers!@NotNull StringGets the package path for relocated libraries@NotNull MessagesProvider<T extends Registrable>
TgetRegistrable(@NotNull Class<T> clazz) Get aRegistrableby its super-class or exact class<T extends Registrable>
TgetRegistrableExact(@NotNull Class<T> clazz) Get aRegistrableby its exact class@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()static voidstatic voidstatic voidLogs a message with the specified level and throwable to the consolevoidlogErrorTrack(@Nullable Object message) voidlogErrorTrack(@Nullable Level level, @Nullable Object message) voidlogErrorTrack(@Nullable Level level, @Nullable Object message, @Nullable Throwable throwable) @Nullable StorageConfig@Nullable StorageConfignewStorageConfig(@NotNull String fileName) final 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
Uses temporary initialization until thepluginis constructed (loaded) -
SERVER_SOFTWARE
-
MINECRAFT_VERSION
@NotNull public static final @NotNull xyz.srnyx.javautilities.objects.SemanticVersion MINECRAFT_VERSION -
options
The API options for the plugin -
libraryManager
-
configLoader
Loader for OkaeriConfig configs -
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 -
updateChecker
-
papiInstalled
public boolean papiInstalledWhether PlaceholderAPI is installed
-
-
Constructor Details
-
AnnoyingPlugin
public AnnoyingPlugin()Constructs a newAnnoyingPlugininstance
-
-
Method Details
-
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:
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:
-
getRegistrable
Get aRegistrableby its super-class or exact class- Type Parameters:
T- The type of theRegistrable- Parameters:
clazz- The class of theRegistrableto get- Returns:
- The
Registrableif it exists, ornullif it doesn't
-
getRegistrableExact
Get aRegistrableby its exact class- Type Parameters:
T- The type of theRegistrable- Parameters:
clazz- The exact class of theRegistrableto get- Returns:
- The
Registrableif it exists, ornullif it doesn't
-
unregisterClasses
public void unregisterClasses()Unregisters allRegistrables inregisteredClasses -
getMessages
-
getAnnoyingMessages
Not overrideable as it would cause aNoClassDefFoundErrorforOkaeriConfigin 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- theOfflinePlayerto parse the placeholders for (ornullif none)message- the message to parse- Returns:
- the parsed message
-
newStorageConfig
-
newStorageConfig
-
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
-
logErrorTrack
-
logErrorTrack
-
logErrorTrack
-
errorTrack
-
errorTrack
-
errorTrack
-
deleteOldFile
-
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
-