org.bukkit.plugin.Plugin.onLoad()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(1.6k)|赞(0)|评价(0)|浏览(156)

本文整理了Java中org.bukkit.plugin.Plugin.onLoad()方法的一些代码示例,展示了Plugin.onLoad()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Plugin.onLoad()方法的具体详情如下:
包路径:org.bukkit.plugin.Plugin
类名称:Plugin
方法名:onLoad

Plugin.onLoad介绍

[英]Called after a plugin is loaded but before it has been enabled.

When mulitple plugins are loaded, the onLoad() for all plugins is called before any onEnable() is called.
[中]在加载插件后但在启用插件之前调用。
加载多个插件时,在调用任何onEnable()之前,会调用所有插件的onLoad()。

代码示例

代码示例来源:origin: GlowstoneMC/Glowstone

plugin.onLoad();
} catch (Exception ex) {
  ConsoleMessages.Error.Plugin.LOADING.log(

代码示例来源:origin: NyaaCat/RPGItems-reloaded

public void loadExtensions() {
  File extDir = new File(plugin.getDataFolder(), "ext");
  if (extDir.isDirectory() || extDir.mkdirs()) {
    File[] files = extDir.listFiles((d, n) -> n.endsWith(".jar"));
    if (files == null) return;
    for (File file : files) {
      try {
        Plugin plugin = Bukkit.getPluginManager().loadPlugin(file);
        String message = String.format("Loading %s", plugin.getDescription().getFullName());
        plugin.getLogger().info(message);
        plugin.onLoad();
        managedPlugins.add(plugin);
        logger.info("Loaded extension: " + plugin.getName());
      } catch (InvalidPluginException | InvalidDescriptionException e) {
        logger.log(Level.SEVERE, "Error loading extension: " + file.getName(), e);
      }
    }
  } else {
    logger.severe("Error creating extension directory ./ext");
  }
}

代码示例来源:origin: Bkm016/TabooLib

e.printStackTrace();
target.onLoad();
try {
  Bukkit.getPluginManager().callEvent(new TPluginEnableEvent(target));

代码示例来源:origin: r-clancy/PlugMan

target.onLoad();
Bukkit.getPluginManager().enablePlugin(target);

相关文章