public static final SystemMessage getSystemMessage(final SystemMessageId smId) { SystemMessage sm = smId.getStaticSystemMessage(); if (sm != null) return sm; sm = new SystemMessage(smId); if (smId.getParamCount() == 0) smId.setStaticSystemMessage(sm); return sm; }
private final void append(final SMParam param) { if (_paramIndex >= _params.length) { _params = Arrays.copyOf(_params, _paramIndex + 1); _smId.setParamCount(_paramIndex + 1); _log.info("Wrong parameter count '" + (_paramIndex + 1) + "' for SystemMessageId: " + _smId); } _params[_paramIndex++] = param; }
@Override protected final void writeImpl() { writeC(0x64); writeD(_smId.getId()); writeD(_paramIndex); SMParam param; for (int i = 0; i < _paramIndex; i++) { param = _params[i]; writeD(param.getType()); switch (param.getType()) { case TYPE_TEXT: { writeS(param.getStringValue()); break; } case TYPE_ITEM_NUMBER: case TYPE_ITEM_NAME: case TYPE_CASTLE_NAME: case TYPE_NUMBER: case TYPE_NPC_NAME: { writeD(param.getIntValue()); break; } case TYPE_SKILL_NAME: { final int[] array = param.getIntArrayValue(); writeD(array[0]); // SkillId writeD(array[1]); // SkillLevel break; } case TYPE_ZONE_NAME: { final int[] array = param.getIntArrayValue(); writeD(array[0]); // x writeD(array[1]); // y writeD(array[2]); // z break; } } } }
private SystemMessage(final SystemMessageId smId) { final int paramCount = smId.getParamCount(); _smId = smId; _params = paramCount != 0 ? new SMParam[paramCount] : EMPTY_PARAM_ARRAY; }
/** * Use {@link #getSystemMessage(SystemMessageId)} where possible instead * * @param id * @return the system message associated to the given Id. */ public static SystemMessage getSystemMessage(int id) { return getSystemMessage(SystemMessageId.getSystemMessageId(id)); }