Class JavaPluginLoader
- All Implemented Interfaces:
PluginLoader
- Author:
- Nukkit Team.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
disablePlugin
(Plugin plugin) 停用一个插件。
Disables a plugin.void
enablePlugin
(Plugin plugin) 启用一个插件。
Enables a plugin.getPluginDescription
(File file) 通过插件的File
对象,来获得描述这个插件的PluginDescription
对象。
Gets aPluginDescription
object describes the plugin by aFile
object describes the plugin file.getPluginDescription
(String filename) 通过插件文件名的字符串,来获得描述这个插件的PluginDescription
对象。
Gets aPluginDescription
object describes the plugin by its file name.Pattern[]
返回这个插件加载器支持的文件类型。
Returns the file types this plugin loader supports.loadPlugin
(File file) 通过插件的File
对象,来加载和初始化一个插件。
Loads and initializes a plugin by aFile
object describes the file.loadPlugin
(String filename) 通过文件名字的字符串,来加载和初始化一个插件。
Loads and initializes a plugin by its file name.
-
Field Details
-
classLoaders
-
-
Constructor Details
-
JavaPluginLoader
-
-
Method Details
-
loadPlugin
Description copied from interface:PluginLoader
通过插件的File
对象,来加载和初始化一个插件。
Loads and initializes a plugin by aFile
object describes the file.这个方法应该设置好插件的相关属性。比如,插件所在的服务器对象,插件的加载器对象,插件的描述对象,插件的数据文件夹。
Properties for loaded plugin should be set in this method. Such as, theServer
object for which this plugin is running in, thePluginLoader
object for its loader, and theFile
object for its data folder.如果插件加载失败,这个方法应该返回
null
,或者抛出异常。
If the plugin loader does not load this plugin successfully, anull
should be returned, or an exception should be thrown.- Specified by:
loadPlugin
in interfacePluginLoader
- Parameters:
file
- 这个插件的文件的File
对象。
AFile
object for this plugin.- Returns:
- 加载完毕的插件的
Plugin
对象。
The loaded plugin as aPlugin
object. - Throws:
Exception
- 插件加载失败所抛出的异常。
Thrown when an error occurred.- See Also:
-
loadPlugin
Description copied from interface:PluginLoader
通过文件名字的字符串,来加载和初始化一个插件。
Loads and initializes a plugin by its file name.这个方法应该设置好插件的相关属性。比如,插件所在的服务器对象,插件的加载器对象,插件的描述对象,插件的数据文件夹。
Properties for loaded plugin should be set in this method. Such as, theServer
object for which this plugin is running in, thePluginLoader
object for its loader, and theFile
object for its data folder.如果插件加载失败,这个方法应该返回
null
,或者抛出异常。
If the plugin loader does not load this plugin successfully, anull
should be returned, or an exception should be thrown.- Specified by:
loadPlugin
in interfacePluginLoader
- Parameters:
filename
- 这个插件的文件名字字符串。
A string of its file name.- Returns:
- 加载完毕的插件的
Plugin
对象。
The loaded plugin as aPlugin
object. - Throws:
Exception
- 插件加载失败所抛出的异常。
Thrown when an error occurred.- See Also:
-
getPluginDescription
Description copied from interface:PluginLoader
通过插件的File
对象,来获得描述这个插件的PluginDescription
对象。
Gets aPluginDescription
object describes the plugin by aFile
object describes the plugin file.如果插件的描述对象获取失败,这个方法应该返回
null
。
If the plugin loader does not get its description successfully, anull
should be returned.- Specified by:
getPluginDescription
in interfacePluginLoader
- Parameters:
file
- 这个插件的文件的File
对象。
AFile
object for this plugin.- Returns:
- 描述这个插件的
PluginDescription
对象。
APluginDescription
object describes the plugin. - See Also:
-
getPluginDescription
Description copied from interface:PluginLoader
通过插件文件名的字符串,来获得描述这个插件的PluginDescription
对象。
Gets aPluginDescription
object describes the plugin by its file name.如果插件的描述对象获取失败,这个方法应该返回
null
。
If the plugin loader does not get its description successfully, anull
should be returned.- Specified by:
getPluginDescription
in interfacePluginLoader
- Parameters:
filename
- 这个插件的文件名字。
A string of its file name.- Returns:
- 描述这个插件的
PluginDescription
对象。
APluginDescription
object describes the plugin. - See Also:
-
getPluginFilters
Description copied from interface:PluginLoader
返回这个插件加载器支持的文件类型。
Returns the file types this plugin loader supports.在Nukkit读取所有插件时,插件管理器会查找所有已经安装的插件加载器,通过识别这个插件是否满足下面的条件, 来选择对应的插件加载器。
When Nukkit is trying to load all its plugins, the plugin manager will look for all installed plugin loader, and choose the correct one by checking if this plugin matches the filters given below.举个例子,识别这个文件是否以jar为扩展名,它的正则表达式是:
For example, to check if this file is has a "jar" extension, the regular expression should be:
^.+\\.jar$
所以只读取jar扩展名的插件加载器,这个函数应该写成:
So, for a jar-extension-only file plugin loader, this method should be:@Override
public Pattern[] getPluginFilters() { return new Pattern[]{Pattern.compile("^.+\\.jar$")}; }- Specified by:
getPluginFilters
in interfacePluginLoader
- Returns:
- 表达这个插件加载器支持的文件类型的正则表达式数组。
An array of regular expressions, that describes what kind of file this plugin loader supports.
-
enablePlugin
Description copied from interface:PluginLoader
启用一个插件。
Enables a plugin.- Specified by:
enablePlugin
in interfacePluginLoader
- Parameters:
plugin
- 要被启用的插件。
The plugin to enable.- See Also:
-
disablePlugin
@PowerNukkitDifference(info="Made impossible to disable special the PowerNukkitPlugin", since="1.3.0.0-PN") public void disablePlugin(Plugin plugin) Description copied from interface:PluginLoader
停用一个插件。
Disables a plugin.- Specified by:
disablePlugin
in interfacePluginLoader
- Parameters:
plugin
- 要被停用的插件。
The plugin to disable.- See Also:
-
getClassLoaders
-