接口 PluginManager

所有已知实现类:
SimplePluginManager

public interface PluginManager
服务器的插件管理器.
  • 方法详细资料

    • registerInterface

      void registerInterface(@NotNull @NotNull Class<? extends PluginLoader> loader) throws IllegalArgumentException
      注册指定的插件加载器.

      原文:Registers the specified plugin loader

      参数:
      loader - 要注册的 PluginLoader 类
      抛出:
      IllegalArgumentException - 当给定的类不是一个有效的 PluginLoader 时抛出
    • getPlugin

      检测指定插件是否已加载并在合适时返回其对象.

      请注意插件名区分大小写.

      原文:Checks if the given plugin is loaded and returns it when applicable

      Please note that the name of the plugin is case-sensitive

      参数:
      name - 要检测的插件的名称
      返回:
      如果此插件存在, 返回对应插件对象, 否则返回null
    • getPlugins

      @NotNull @NotNull Plugin[] getPlugins()
      获取所有已载入的插件对象.

      原文: Gets a list of all currently loaded plugins.

      返回:
      返回类型为Plugin的数组
    • isPluginEnabled

      boolean isPluginEnabled(@NotNull @NotNull String name)
      检测指定插件是否已启用.

      请注意插件名区分大小写.

      原文:Checks if the given plugin is enabled or not

      Please note that the name of the plugin is case-sensitive.

      参数:
      name - 要检测的插件的名称
      返回:
      如果此插件已启用, 返回true
    • isPluginEnabled

      @Contract("null -> false") boolean isPluginEnabled(@Nullable @Nullable Plugin plugin)
      检查指定插件是否启用.

      原文: Checks if the given plugin is enabled or not.

      参数:
      plugin - 要检测的插件的对象
      返回:
      如果此插件已启用, 返回true
    • loadPlugin

      加载某个文件为插件.

      文件必须对当前的插件加载器有效才会被加载.

      原文:Loads the plugin in the specified file

      File must be valid according to the current enabled Plugin interfaces

      参数:
      file - 要加载的插件文件
      返回:
      加载成功后的插件对象, 若插件文件无效返回null
      抛出:
      InvalidPluginException - 若指定文件不是一个有效的插件
      InvalidDescriptionException - 若插件包含一个无效的插件描述文件(plugin.yml)
      UnknownDependencyException - 若插件要求的依赖找不到
    • loadPlugins

      @NotNull @NotNull Plugin[] loadPlugins(@NotNull @NotNull File directory)
      载入指定目录内的插件.

      原文: Loads the plugins contained within the specified directory.

      参数:
      directory - 指定目录的File对象
      返回:
      返回带有已成功载入的插件Plugin对象的数组
    • disablePlugins

      void disablePlugins()
      停用所有已载入的插件.

      原文: Disables all the loaded plugins.

    • clearPlugins

      void clearPlugins()
      停用并清除所有已启用插件的Plugin对象.

      原文: Disables and removes all plugins.

    • callEvent

      void callEvent(@NotNull @NotNull Event event) throws IllegalStateException
      调用一个具有详细信息的事件.

      译注:(针对 Bukkkit 中对本接口的唯一实现SimplePluginManager来说)本方法是线程安全的, 但不可以在同步代码块/同步线程中触发异步事件, 也不可以从异步线程中触发同步事件.

      原文:Calls an event with the given details

      参数:
      event - 事件
      抛出:
      IllegalStateException - 当从同步代码中触发异步事件时抛出

      注意:这是插件开发者应尽的义务, 不应用其来测试同步状态. 这是逻辑流有缺陷的迹象

    • registerEvents

      void registerEvents(@NotNull @NotNull Listener listener, @NotNull @NotNull Plugin plugin)
      注册在指定监听器类中的所有事件.

      原文:Registers all the events in the given listener class

      参数:
      listener - 要注册的监听器
      plugin - 注册事件的插件
    • registerEvent

      void registerEvent(@NotNull @NotNull Class<? extends Event> event, @NotNull @NotNull Listener listener, @NotNull @NotNull EventPriority priority, @NotNull @NotNull EventExecutor executor, @NotNull @NotNull Plugin plugin)
      将指定的执行器注册至指定的事件类.

      原文:Registers the specified executor to the given event class

      参数:
      event - 要注册的事件类型
      listener - 要注册的监听器
      priority - 要注册的事件的优先级
      executor - 要注册的EventExecutor
      plugin - 注册事件的插件
    • registerEvent

      void registerEvent(@NotNull @NotNull Class<? extends Event> event, @NotNull @NotNull Listener listener, @NotNull @NotNull EventPriority priority, @NotNull @NotNull EventExecutor executor, @NotNull @NotNull Plugin plugin, boolean ignoreCancelled)
      将指定的执行器注册至指定的事件类.

      原文:Registers the specified executor to the given event class

      参数:
      event - 要注册的事件类型
      listener - 要注册的监听器
      priority - 要注册的事件的优先级
      executor - 要注册的EventExecutor
      plugin - 注册事件的插件
      ignoreCancelled - 是否忽略已取消的事件
    • enablePlugin

      void enablePlugin(@NotNull @NotNull Plugin plugin)
      启用指定插件.

      尝试启用一个已启用的插件, 什么都不会发生.

      原文:Enables the specified plugin

      Attempting to enable a plugin that is already enabled will have no effect

      参数:
      plugin - 要启用的插件
    • disablePlugin

      void disablePlugin(@NotNull @NotNull Plugin plugin)
      停用指定的插件.

      尝试停用一个已停用的插件, 什么都不会发生.

      原文:Disables the specified plugin

      Attempting to disable a plugin that is not enabled will have no effect

      参数:
      plugin - 要停用的插件
    • getPermission

      以指定的完整权限节点获取对应Permission对象.

      原文:Gets a Permission from its fully qualified name

      参数:
      name - Name of the permission
      返回:
      对应Permission对象, 若权限节点不存在返回null
    • addPermission

      void addPermission(@NotNull @NotNull Permission perm)
      添加一个Permission至本插件管理器.

      如果已有同名权限, 会抛出一个异常.

      原文:Adds a Permission to this plugin manager.

      If a permission is already defined with the given name of the new permission, an exception will be thrown.

      参数:
      perm - 要添加的权限
      抛出:
      IllegalArgumentException - 如果同名权限已存在
    • removePermission

      void removePermission(@NotNull @NotNull Permission perm)
      从本插件管理器中移除已注册的权限.

      如果指定的权限未在本插件管理器中注册, 什么都不会发生.

      原文:Removes a Permission registration from this plugin manager.

      If the specified permission does not exist in this plugin manager, nothing will happen.

      Removing a permission registration will not remove the permission from any Permissibles that have it.

      参数:
      perm - 要移除的权限
    • removePermission

      void removePermission(@NotNull @NotNull String name)
      从本插件管理器中移除已注册的权限.

      如果指定的权限未在本插件管理器中注册, 什么都不会发生.

      原文:Removes a Permission registration from this plugin manager.

      If the specified permission does not exist in this plugin manager, nothing will happen.

      Removing a permission registration will not remove the permission from any Permissibles that have it.

      参数:
      name - 要移除的权限
    • getDefaultPermissions

      @NotNull @NotNull Set<Permission> getDefaultPermissions(boolean op)
      获取普通玩家默认拥有的权限或op默认拥有的权限.

      原文: Gets the default permissions for the given op status

      参数:
      op - 是否获取op状态下默认拥有的权限
      返回:
      返回 普通玩家/OP 默认拥有的权限
    • recalculatePermissionDefaults

      void recalculatePermissionDefaults(@NotNull @NotNull Permission perm)
      重新计算指定权限的默认值.

      若指定的权限未在本插件管理器注册, 将没有效果.

      原文:Recalculates the defaults for the given Permission.

      This will have no effect if the specified permission is not registered here.

      参数:
      perm - 要重算的权限
    • subscribeToPermission

      void subscribeToPermission(@NotNull @NotNull String permission, @NotNull @NotNull Permissible permissible)
      以指定的权限名订阅与其有关的 Permissible.

      若指定的权限以任何形式改变, 要求重新计算传入的Permissible.

      原文:Subscribes the given Permissible for information about the requested Permission, by name.

      If the specified Permission changes in any form, the Permissible will be asked to recalculate.

      参数:
      permission - 要订阅的权限
      permissible - 要订阅的Permissible
    • unsubscribeFromPermission

      void unsubscribeFromPermission(@NotNull @NotNull String permission, @NotNull @NotNull Permissible permissible)
      以指定的权限名退订与其有关的 Permissible.

      原文:Unsubscribes the given Permissible for information about the requested Permission, by name.

      参数:
      permission - 要退订的权限
      permissible - 已订阅的Permissible
    • getPermissionSubscriptions

      @NotNull @NotNull Set<Permissible> getPermissionSubscriptions(@NotNull @NotNull String permission)
      根据权限名获取此权限已订阅的Permissible的集合.

      原文:Gets a set containing all subscribed Permissibles to the given permission, by name

      参数:
      permission - 要检索的权限
      返回:
      包含此权限已订阅的所有Permissible的集合
    • subscribeToDefaultPerms

      void subscribeToDefaultPerms(boolean op, @NotNull @NotNull Permissible permissible)
      为普通玩家/op默认权限订阅指定Permissible.

      若指定的默认权限列表以任何形式改动, 要求重新计算传入的Permissible.

      原文:Subscribes to the given Default permissions by operator status

      If the specified defaults change in any form, the Permissible will be asked to recalculate.

      参数:
      op - 是否根据op的默认权限列表订阅
      permissible - 要订阅的Permissible
    • unsubscribeFromDefaultPerms

      void unsubscribeFromDefaultPerms(boolean op, @NotNull @NotNull Permissible permissible)
      退订普通玩家/op默认权限已订阅的Permissible.

      原文:Unsubscribes from the given Default permissions by operator status

      参数:
      op - 是否根据op的默认权限列表退订
      permissible - 权限已订阅的Permissible
    • getDefaultPermSubscriptions

      @NotNull @NotNull Set<Permissible> getDefaultPermSubscriptions(boolean op)
      获取普通玩家/op默认权限列表已订阅的Permissible.

      原文:Gets a set containing all subscribed Permissibles to the given default list, by op status

      参数:
      op - 是否根据op的默认权限列表检索
      返回:
      包含所有权限订阅者的集合
    • getPermissions

      @NotNull @NotNull Set<Permission> getPermissions()
      获取已注册的权限的集合.

      此集合是一个副本, 对其编辑不会作用于内部的权限列表.

      原文:Gets a set of all registered permissions.

      This set is a copy and will not be modified live.

      返回:
      包含所有已注册权限的集合
    • useTimings

      boolean useTimings()
      返回是否在事件调用中使用插件计时器.

      译注:Timings是一个性能分析工具, 通过Timings可以了解 服务器的性能损耗情况, 通过它可以定位插件/服务器代码中性能较差的方法, 并针对性地进行优化. 可以通过"/timings on"开始记录, "/timings paste"上传记录, "/timings off"关闭记录 (仅针对Spigot及其衍生服务端).

      原文:Returns whether or not timing code should be used for event calls

      返回:
      若已启用Timings