Package top.focess.qq.api.plugin
Class Plugin
- java.lang.Object
-
- top.focess.qq.api.plugin.Plugin
-
- Direct Known Subclasses:
LazyPlugin,Main.MainPlugin
public abstract class Plugin extends Object
Represent a Plugin class that can be load, enable and disable. Also, provide plenty of API for the plugin to get better with this framework. You should declarePluginTypeto this class.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract voiddisable()Used to save some data of the pluginabstract voidenable()Used to initialize the pluginbooleanequals(Object o)StringgetAuthor()@NotNull YamlConfigurationgetConfig()@NotNull FilegetConfigFile()DefaultConfiggetDefaultConfig()@NotNull FilegetDefaultFolder()LangConfiggetLangConfig()@NotNull StringgetName()static PlugingetPlugin(Class<? extends Plugin> plugin)Get Plugin instance by the class instancestatic PlugingetPlugin(String name)Get Plugin instance by the namePluginDescriptiongetPluginDescription()VersiongetVersion()inthashCode()booleanisEnabled()InputStreamloadResource(String path)voidonDisable()voidonEnable()voidregisterBuffer(DataConverter<?> dataConverter, DataCollection.BufferGetter bufferGetter)Register the getter of the buffervoidregisterCommand(Command command)Register the commandvoidregisterListener(Listener listener)Register the listener into the Event chainstatic @Nullable PluginthisPlugin()
-
-
-
Constructor Detail
-
Plugin
public Plugin(String name, String author, Version version)
Initialize a Plugin instance by its name. Never instance it! It will be instanced when bot bootstraps automatically.- Parameters:
name- the plugin nameauthor- the plugin authorversion- the plugin version- Throws:
PluginLoaderException- if the classloader of the plugin is notPluginClassLoader
-
Plugin
protected Plugin()
Provide a constructor to helpPluginTypedesign. Never instance it! It will be instanced when bot bootstraps automatically.
-
-
Method Detail
-
getPlugin
public static Plugin getPlugin(Class<? extends Plugin> plugin)
Get Plugin instance by the class instance- Parameters:
plugin- the class instance of the plugin- Returns:
- the plugin instance
- See Also:
PluginClassLoader.getPlugin(Class)
-
getPlugin
public static Plugin getPlugin(String name)
Get Plugin instance by the name- Parameters:
name- the name of the plugin- Returns:
- the plugin instance
- See Also:
PluginClassLoader.getPlugin(String)
-
thisPlugin
@Nullable public static @Nullable Plugin thisPlugin()
-
getName
@NotNull public @NotNull String getName()
-
enable
public abstract void enable()
Used to initialize the plugin
-
disable
public abstract void disable()
Used to save some data of the plugin
-
onEnable
public final void onEnable()
-
onDisable
public final void onDisable()
-
getDefaultFolder
@NotNull public @NotNull File getDefaultFolder()
-
getConfigFile
@NotNull public @NotNull File getConfigFile()
-
getConfig
@NotNull public @NotNull YamlConfiguration getConfig()
-
registerListener
public void registerListener(Listener listener)
Register the listener into the Event chain- Parameters:
listener- the listener need to be registered
-
registerCommand
public void registerCommand(Command command)
Register the command- Parameters:
command- the command need to be registered
-
registerBuffer
public void registerBuffer(DataConverter<?> dataConverter, DataCollection.BufferGetter bufferGetter)
Register the getter of the buffer- Parameters:
dataConverter- the buffer data converterbufferGetter- the getter of the buffer
-
getAuthor
public String getAuthor()
-
getVersion
public Version getVersion()
-
getLangConfig
public LangConfig getLangConfig()
-
getDefaultConfig
public DefaultConfig getDefaultConfig()
-
getPluginDescription
public PluginDescription getPluginDescription()
-
loadResource
public InputStream loadResource(String path)
-
isEnabled
public boolean isEnabled()
-
-