Class UltiToolsPlugin
- All Implemented Interfaces:
Configurable,IPlugin,Localized
插件模块抽象类
- Version:
- 1.0.0
- Author:
- wisdomme
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedConstructor for UltiToolsPlugin.UltiToolsPlugin(String pluginName, String version, List<String> authors, List<String> loadAfter, int minUltiToolsVersion, String mainClass) Deprecated, for removal: This API element is subject to removal in a future version.UltiToolsPlugin(String pluginName, String version, List<String> authors, List<String> loadAfter, int minUltiToolsVersion, String mainClass, String resourceFolderPath) Constructor for UltiToolsPlugin. -
Method Summary
Modifier and TypeMethodDescriptionprivate LanguagecreateLanguageFromPath(String folderPath) Creates a Language object from the given resource folder pathstatic CommandManager<T extends AbstractConfigEntity>
TGet config by config type.<T extends AbstractConfigEntity>
TGet config by config path and config type.protected final FilegetConfigFile(String path) protected final Stringstatic ConfigManager<T extends AbstractConfigEntity>
List<T> getConfigs(Class<T> configType) final <T extends BaseDataEntity<String>>
DataOperator<T> getDataOperator(Class<T> dataClazz) Gets data operator.private InputStreamfinal Languagefinal Stringstatic ListenerManagerstatic PluginManagerprivate InputStreamgetResource(String filename) static VersionWrapperDeprecated, for removal: This API element is subject to removal in a future version.UseXVersionUtilsinstead.final StringReturns a localized string that indicated by user.private voidInitializes the configuration entity.private LanguageInitializes the language objectbooleanisNewerVersionThan(UltiToolsPlugin plugin) private org.bukkit.configuration.file.YamlConfigurationLoads the plugin configuration from plugin.ymlvoidUltiTools will call this method when reloading this plugin module, similar toJavaPlugin.onDisable()andJavaPlugin.onEnable()
重载此插件模块时调用的方法,此重载并非重启模块,不会调用IPlugin.registerSelf()和IPlugin.unregisterSelf()。<T extends AbstractConfigEntity>
voidsaveConfig(String path, Class<T> configType) Save config by config type.private voidvoidsetContext(SimpleContainer context) Injects the IoC container created for this plugin.voidUltiTools will call this method when unregistering this plugin module, similar toJavaPlugin.onDisable()
卸载此插件模块时调用的方法,类比JavaPlugin.onDisable()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.ultikits.ultitools.interfaces.Configurable
getAllConfigsMethods inherited from interface com.ultikits.ultitools.interfaces.IPlugin
registerSelf
-
Field Details
-
language
-
version
-
pluginName
-
authors
-
loadAfter
-
minUltiToolsVersion
private final int minUltiToolsVersion -
mainClass
-
identifyString
-
resourceFolderPath
-
context
-
-
Constructor Details
-
UltiToolsPlugin
protected UltiToolsPlugin()Constructor for UltiToolsPlugin. For module development only.UltiToolsPlugin的构造函数。仅用于模块开发。
-
UltiToolsPlugin
@Deprecated(since="6.0.8", forRemoval=true) public UltiToolsPlugin(String pluginName, String version, List<String> authors, List<String> loadAfter, int minUltiToolsVersion, String mainClass) Deprecated, for removal: This API element is subject to removal in a future version.Use the seven-argument constructor and passresourceFolderPathexplicitly. This overload hard-codes it to<dataFolder>/pluginConfig/<pluginName>.请改用七参数构造函数并显式传入
resourceFolderPath。 此重载把它硬编码成了<dataFolder>/pluginConfig/<插件名>。Constructor for UltiToolsPlugin. For plugin connector.UltiToolsPlugin的构造函数。用于插件连接器。
- Parameters:
pluginName- the name of the plugin
插件名称version- the version of the plugin
插件版本authors- the authors of the plugin
插件作者loadAfter- the plugins which should be loaded before this plugin
在这个插件之前加载的插件minUltiToolsVersion- the minimum version of UltiTools required by this plugin
这个插件所需的UltiTools最低版本mainClass- the main class of the plugin
插件的主类
-
UltiToolsPlugin
public UltiToolsPlugin(String pluginName, String version, List<String> authors, List<String> loadAfter, int minUltiToolsVersion, String mainClass, String resourceFolderPath) Constructor for UltiToolsPlugin. For plugin connector.UltiToolsPlugin的构造函数。用于插件连接器。
- Parameters:
pluginName- the name of the plugin
插件名称version- the version of the plugin
插件版本authors- the authors of the plugin
插件作者loadAfter- the plugins which should be loaded before this plugin
在这个插件之前加载的插件minUltiToolsVersion- the minimum version of UltiTools required by this plugin
这个插件所需的UltiTools最低版本mainClass- the main class of the plugin
插件的主类resourceFolderPath- the path to the resource folder
资源文件夹的路径
-
-
Method Details
-
initializeLanguage
Initializes the language object- Returns:
- Language object
-
createLanguageFromPath
Creates a Language object from the given resource folder path- Parameters:
folderPath- the resource folder path- Returns:
- Language object
-
loadPluginConfiguration
private org.bukkit.configuration.file.YamlConfiguration loadPluginConfiguration()Loads the plugin configuration from plugin.yml- Returns:
- YamlConfiguration object with default values if loading fails
-
setContext
Injects the IoC container created for this plugin.注入为本插件创建的 IoC 容器。
Called by
PluginManagerwhile a module is being loaded, beforeregisterSelf()runs. It is not part of the module-facing API — a module that calls it replaces the container the framework already wired up, losing every bean that was injected into it.由
PluginManager在加载模块时调用,早于registerSelf()。它不属于 面向模块的 API——模块自己调用它,等于把框架已经装配好的容器整个换掉,里面注入过的 bean 全部丢失。Deliberately still public:
PluginManagerlives in another package, so this cannot be narrowed to package-private, and deleting it outright would remove a public method, which the compatibility policy forbids in a PATCH release. The annotation is a signal to humans and IDEs; it enforces nothing at runtime.刻意保持 public:
PluginManager不在同一个包,降不成 package-private; 直接删掉则是移除一个 public 方法,兼容性策略不允许 PATCH 版本这么做。注解只是给人 和 IDE 看的信号,运行期不做任何强制。- Parameters:
context- the container created for this plugin
为本插件创建的容器
-
getConfigManager
- Returns:
- the config manager
配置管理器
-
getListenerManager
- Returns:
- the listener manager
监听器管理器
-
getCommandManager
- Returns:
- the command manager
指令管理器
-
getPluginManager
- Returns:
- the plugin manager
插件管理器
-
getVersionWrapper
Deprecated, for removal: This API element is subject to removal in a future version.UseXVersionUtilsinstead.- Returns:
- the version wrapper
版本包装器
-
initConfig
Initializes the configuration entity.初始化配置实体。
- Throws:
IOException
-
getInputStream
- Throws:
IOException
-
getConfigFolder
-
getConfigFile
-
getConfig
Description copied from interface:ConfigurableGet config by config type.通过配置类型获取配置
- Specified by:
getConfigin interfaceConfigurable- Type Parameters:
T- Config type
配置类型- Parameters:
configType- Config type
配置类型- Returns:
- Config
配置
-
getConfig
Description copied from interface:ConfigurableGet config by config path and config type.通过配置路径和配置类型获取配置
- Specified by:
getConfigin interfaceConfigurable- Type Parameters:
T- Config type
配置类型- Parameters:
path- Config path
配置路径configType- Config type
配置类型- Returns:
- Config
配置
-
getConfigs
-
saveConfig
public <T extends AbstractConfigEntity> void saveConfig(String path, Class<T> configType) throws IOException Description copied from interface:ConfigurableSave config by config type.通过配置类型保存配置
- Specified by:
saveConfigin interfaceConfigurable- Type Parameters:
T- Config type
配置类型- Parameters:
path- Config path
配置路径configType- Config type
配置类型- Throws:
IOException- IOException
IO异常
-
saveResources
private void saveResources() -
getResource
-
getDataOperator
Gets data operator.获取数据操作器。
- Type Parameters:
T- the type of the data entity
数据实体的类型- Parameters:
dataClazz- the class of the data entity
数据实体的类- Returns:
- the data operator
数据操作器
-
getLanguageCode
- Returns:
- language code
语言代码
-
getLanguage
- Returns:
- the language
语言
-
i18n
- Parameters:
str- the string to be localized
要本地化的字符串- Returns:
- the localized string
本地化后的字符串
-
i18n
Description copied from interface:LocalizedReturns a localized string that indicated by user. If the chosen language code is not presented inLocalized.supported(), this method will return the text by default.
通过指定的语言代码返回一个本地化的字符串。如果语言代码没有出现在Localized.supported()里面,则返回传入的原文。 -
isNewerVersionThan
- Parameters:
plugin- the plugin to be checked
要检查的插件- Returns:
- whether the plugin is newer than the given plugin
插件是否比给定的插件新
-
unregisterSelf
public void unregisterSelf()Description copied from interface:IPluginUltiTools will call this method when unregistering this plugin module, similar toJavaPlugin.onDisable()
卸载此插件模块时调用的方法,类比JavaPlugin.onDisable()- Specified by:
unregisterSelfin interfaceIPlugin
-
reloadSelf
public void reloadSelf()Description copied from interface:IPluginUltiTools will call this method when reloading this plugin module, similar toJavaPlugin.onDisable()andJavaPlugin.onEnable()
重载此插件模块时调用的方法,此重载并非重启模块,不会调用IPlugin.registerSelf()和IPlugin.unregisterSelf()。- Specified by:
reloadSelfin interfaceIPlugin
-
getLogger
- Returns:
- plugin logger
插件日志发送器
-
resourceFolderPathexplicitly.