/** * 获取用户当前阵型 * * @param player */ public void getForm(Player player) { // 获取用户当前对应的阵型配置,找不到配置直接返回错误 Human human = player.getHuman(); FormTemplate template = getFormTemplate(human.getVocationType(), human.getLevel()); if (template == null) { player.sendErrorPromptMessage(SkillLangConstants_80000.TEMPLATE_NOT_FOUND); return; } // 获取用户当前阵法,找不到则初始化阵法 BattleForm form = human.getBattleForm(); if (form == null) { form = initBattleForm(human, template); } String[] positions = form.getPositions(); // 根据当前阵法和阵法配置构造返回消息 List<FormPosition> list = new ArrayList<FormPosition>(); for (int open : template.getOpenPositions()) { if (open > 0 && open <= positions.length && StringUtils.isNotEmpty(positions[open - 1])) { list.add(new FormPosition(open, positions[open - 1])); } else { list.add(new FormPosition(open, "-1")); } } // 返回初始化消息 GCForm msg = new GCForm(); msg.setFormPositions(list.toArray(new FormPosition[0])); msg.setMaxPos(template.getMaxPos()); player.sendMessage(msg); }