Interface GroovyScript

  • All Implemented Interfaces:
    cn.org.bukkit.craneattribute.api.lifecycle.LifecycleAware

    
    public interface GroovyScript
     implements LifecycleAware
                        

    Groovy 脚本扩展接口

    用于定义可通过 Groovy 脚本动态注入的可执行逻辑模块, 支持在运行时通过命令触发, 并具备完整的生命周期管理(启用/禁用回调),便于资源清理与重载。

    • 自定义调试命令

    • 动态属性计算逻辑

    • 临时事件响应器

    • 管理员工具脚本

    注意:所有实现应保证线程安全,且避免长时间阻塞主线程。

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      Unit onEnable() 脚本启用时回调。在脚本首次加载或插件重载后调用。 可用于初始化变量、注册监听器、连接外部服务等。默认为空实现,子类或脚本按需重写。
      Unit onDisable() 脚本禁用时回调。在插件关闭、脚本重载前或显式卸载时调用。 应在此释放资源(如定时任务、文件句柄、网络连接), 防止内存泄漏或状态残留。默认为空实现。
      Unit invoke(CommandSender sender, String string) 执行脚本主逻辑。参数 string 对应命令后的所有字符串参数。
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

    • Method Detail

      • onEnable

         Unit onEnable()

        脚本启用时回调。

        在脚本首次加载或插件重载后调用。 可用于初始化变量、注册监听器、连接外部服务等。

        默认为空实现,子类或脚本按需重写。

      • onDisable

         Unit onDisable()

        脚本禁用时回调。

        在插件关闭、脚本重载前或显式卸载时调用。 应在此释放资源(如定时任务、文件句柄、网络连接), 防止内存泄漏或状态残留。

        默认为空实现。

      • invoke

         Unit invoke(CommandSender sender, String string)

        执行脚本主逻辑。

        参数 string 对应命令后的所有字符串参数。

        Parameters:
        sender - 命令执行者(玩家或控制台)
        string - 用户传入的参数列表(可变长度)默认为空操作,建议在具体脚本中实现业务逻辑。