MapManager (地图管理器-实现自定义图像在地图上的显示)
MapManager 是一个用于在 Minecraft 中显示自定义图像的高级 API,允许开发者将图像显示在地图上,并可将个性化的地图发送给玩家。其主要特色在于能够快速更新地图内容(如动画帧),因为地图数据可以发送给玩家,并在之后改变物品框架中或玩家库存中显示的地图。
功能和特点
- 将任意自定义图像包装并显示在地图上。
- 支持向指定玩家发送个性化地图。
- 支持地图内容的快速更新,适合动态内容展示。
- 对于开发者友好,通过简单的 API 调用实现上述功能。
依赖
MapManager 需要 PacketListenerAPI 作为依赖才能正常工作。
使用方法
try{ //获取 MapManager 实例 MapManager mapManager = ((MapManagerPlugin)Bukkit.getPluginManager().getPlugin("MapManager")).getMapManager(); //包装本地文件 "myImage.png" 成地图 MapWrapper mapWrapper = mapManager.wrapImage(ImageIO.read(new File("myImage.png"))); MapController mapController = mapWrapper.getController(); //添加 "inventivetalent" 为观看者,并发送内容 mapController.addViewer(Bukkit.getPlayer("inventivetalent")); mapController.sendContent(Bukkit.getPlayer("inventivetalent")); //在物品框架中显示图像 mapController.showInFrame(Bukkit.getPlayer("inventivetalent"), null); //或直接在手中显示 mapController.showInHand(Bukkit.getPlayer("inventivetalent")); }catch(IOException e){ e.printStackTrace(); }
命令
/mapmanager reload
- 重新加载配置文件
权限
mapmanager.reload - 允许重新加载配置文件的权限
配置
是否允许向玩家发送原版地图(较低效,因为我们需要检查每个发送的地图ID)
allowVanilla: true改变此数值以“保留”一定数量的地图ID,这些ID不会被 MapManager 插件使用
forcedOffset: 0是否在创建新图像前检查重复的图像(首次创建图像时效率较低,但整体上更高效)
checkDuplicates: true在图像对象中缓存数据包数据(对于大量玩家来说,CPU占用较低,但根据图像大小可能会稍微增加内存占用)
cacheData: true sender: # 地图数据包之间的延迟(以tick为单位) delay: 2 # 一次性发送的最大地图数据包数量 amount: 10 # 允许立即发送地图数据 allowQueueBypass: true # 如果你在使用PaperSpigot(或者碰到这个错误:链接 paperSpigot: false
收录