桥

一个强大的Hytale插件库,用于轻松创建、管理和编排临时世界。

图书馆

Bridge - Hytale 世界管理库

一个强大的 Hytale 插件库,用于轻松创建、管理和编排临时世界。Bridge 提供了强大的 API 来处理世界生命周期、玩家转移和可定制的世界行为。

✨ 特性

  • 轻松的世界管理:通过简单的 API 调用创建、激活、停用和删除世界
  • 玩家转移:内置线程安全,安全地在世界之间移动玩家
  • 自定义世界行为:扩展 BridgeWorldComponent 为世界添加自定义逻辑
  • 异步操作:大多数操作异步运行,支持可选回调
  • 世界配置:控制方块破坏、放置、采集和 PvP 设置
  • 生命周期事件:挂钩世界创建、删除和玩家事件

📖 API 参考

BridgeWorldManager:

  1. createWorld(String name, BridgeWorldComponent component, Consumer callback)
  2. getAllVBridgeWorlds() - 获取所有管理的世界
  3. getDefaultWorldAsBridgeWorld() - 获取默认世界
  4. deleteWorld(BridgeWorld world) - 永久删除世界
  5. activateWorld(BridgeWorld world, Consumer callback)
  6. deactivateWorld(BridgeWorld world, World movePlayersTo)

BridgeWorld:

  1. activate(Consumer callback) - 将世界加载到内存中
  2. deactivate(World movePlayersTo) - 卸载世界
  3. transferPlayer(PlayerRef player) - 将玩家转移到此世界
  4. delete() - 删除此世界及其文件
  5. setAllowPvP(boolean enabled) - 切换 PvP
  6. setAllowBlockBreaking(boolean enabled) - 切换方块破坏

BridgeWorldComponent 生命周期方法:

  1. onCreateWorld(BridgeWorld world) - 世界创建时
  2. onDeleteWorld(BridgeWorld world) - 世界删除前
  3. onPlayerJoinWorld(BridgeWorld world, PlayerRef player)
  4. onPlayerLeaveWorld(BridgeWorld world, PlayerRef player)
  5. onPlayerDieInWorld(BridgeWorld world, PlayerRef player)
  6. onTick(BridgeWorld world, float deltaTime) - 每个游戏刻调用