"""插件管理器 - 直接使用框架层的 Core Engine""" from typing import Any, Optional from oss.core.engine import PluginManager as CorePluginManager # 深度隐藏的成就系统导入 try: from oss.core.achievements import get_validator _ACHIEVEMENTS_ENABLED = True except ImportError: _ACHIEVEMENTS_ENABLED = False class PluginManager: """极简插件管理器 直接使用框架层的 CorePluginManager(原 Core 插件功能) - 不再通过插件加载器加载 Core - 所有核心功能直接集成在 oss.core.engine 中 """ def __init__(self): self.core = CorePluginManager() def load(self): """加载所有插件(由 CorePluginManager 管理)""" self.core.load_all() # 隐藏成就:深海潜水员 if _ACHIEVEMENTS_ENABLED: try: validator = get_validator() validator.unlock("deep_diver") except Exception as e: print(f"[PluginManager] 错误: {e}") def start(self): """启动 Core,它会初始化并启动所有其他插件""" import time start_time = time.time() self.core.init_and_start_all() # 启动 HTTP 服务 self.core.start_http_server() # 启动防篡改监控 self.core.start_tamper_monitor() # 计算启动时间并检查速度成就 elapsed_ms = (time.time() - start_time) * 1000 if _ACHIEVEMENTS_ENABLED: try: validator = get_validator() validator.check_startup_speed(elapsed_ms) # 检查插件数量成就 plugin_count = len(self.core.plugins) validator.check_plugin_count(plugin_count) except Exception as e: print(f"[PluginManager] 错误: {e}") def stop(self): """停止所有插件""" try: self.core.stop_tamper_monitor() self.core.stop_http_server() self.core.stop_all() except KeyboardInterrupt: print("[PluginManager] 用户中断停止过程") except Exception as e: import traceback print(f"[PluginManager] 停止插件时出错:{type(e).__name__}: {e}") traceback.print_exc() # 隐藏成就:崩溃幸存者 if _ACHIEVEMENTS_ENABLED: try: validator = get_validator() validator.track_progress("session_end") except Exception as e: print(f"[PluginManager] 错误: {e}")