↑ ↓

Объява в легионе

Тема в разделе "Помощь", создана пользователем nokiafan1111, 11 май 2018.

  1. TopicStarter Overlay
    Offline

    nokiafan1111 Ефрейтор

    331
    21
    51
    Кредиты:
    $329,63
    Репутация:
    2
    Сборка 4.9 геров)
    Копался в пакетке, чет не понял как именно сделать, чтобы объяву в леге отображало? А то пишу любое сообщение в объяве, а оно не отображается, в базе есть, и даже при входе в игру в чате показывает.
    Может кто помочь разобраться?:D

    Вот клиентский пакет
    Код:
    public class CM_LEGION extends AionClientPacket {
    
    	private static final Logger log = LoggerFactory.getLogger(CM_LEGION.class);
    	/**
    	 * exOpcode and the rest
    	 */
    	private int exOpcode;
    	private short deputyPermission;
    	private short centurionPermission;
    	private short legionarPermission;
    	private short volunteerPermission;
    	private int rank;
    	private String legionName;
    	private String charName;
    	private String newNickname;
    	private String announcement;
    	private String newSelfIntro;
    	private String joinDescription;
    	private int joinType;
    	private int minLevel;
    	private int playerId;
    
    	/**
    	 * Constructs new instance of CM_LEGION packet
    	 *
    	 * @param opcode
    	 */
    	public CM_LEGION(int opcode, State state, State... restStates) {
    		super(opcode, state, restStates);
    	}
    
    	/**
    	 * {@inheritDoc}
    	 */
    	@Override
    	protected void readImpl() {
    		exOpcode = readC();
    
    		switch (exOpcode) {
    			/**
    			 * Create a legion *
    			 */
    			case 0x00:
    				readD(); // 00 78 19 00 40
    				legionName = readS();
    				break;
    			/**
    			 * Invite to legion *
    			 */
    			case 0x01:
    				readD(); // empty
    				charName = readS();
    				break;
    			/**
    			 * Leave legion *
    			 */
    			case 0x02:
    				readD(); // empty
    				readH(); // empty
    				break;
    			/**
    			 * Kick member from legion *
    			 */
    			case 0x04:
    				readD(); // empty
    				charName = readS();
    				break;
    			/**
    			 * Appoint a new Brigade General *
    			 */
    			case 0x05:
    				readD();
    				charName = readS();
    				break;
    			/**
    			 * Appoint Centurion *
    			 */
    			case 0x06:
    				rank = readD();
    				charName = readS();
    				break;
    			/**
    			 * Demote to Legionary *
    			 */
    			case 0x07:
    				readD(); // char id? 00 78 19 00 40
    				charName = readS();
    				break;
    			/**
    			 * Refresh legion info *
    			 */
    			case 0x08:
    				readD();
    				readH();
    				break;
    			/**
    			 * Edit announcements *
    			 */
    			case 0x09:
    				readD(); // empty or char id?
    				announcement = readS();
    				break;
    			/**
    			 * Change self introduction *
    			 */
    			case 0x0A:
    				readD(); // empty char id?
    				newSelfIntro = readS();
    				break;
    			/**
    			 * Edit permissions *
    			 */
    			case 0x0D:
    				deputyPermission = (short) readH();
    				centurionPermission = (short) readH();
    				legionarPermission = (short) readH();
    				volunteerPermission = (short) readH();
    				break;
    			/**
    			 * Level legion up *
    			 */
    			case 0x0E:
    				readD(); // empty
    				readH(); // empty
    				break;
    			case 0x0F:
    				charName = readS();
    				newNickname = readS();
    				break;
    			/**
    			 * Change Legion Join Description   
    			 */
    			case 0x11:
    				joinDescription = readS();
    				break;
    			/**
    			 * Change Legion Recruit Type
    			 * 0 : can Join / 1 : can join after request / 2: join legion via legionSearch is disabled.
    			 */
    			case 0x12:
    				joinType = readC();
    				break;
    			//change recruitMinLevel
    			case 0x13:
    				minLevel = readH();
    				break;
    			//accept Legion Join Request from Player   
    			case 0x14:
    				playerId = readD();
    				break;
    			//deny Legion Join Request from Player   
    			case 0x15:
    				playerId = readD();
    				break;
    			default:
    				log.info("Unknown Legion exOpcode? 0x" + Integer.toHexString(exOpcode).toUpperCase());
    				break;
    		}
    	}
    
    	/**
    	 * {@inheritDoc}
    	 */
    	@Override
    	protected void runImpl() {
    		final Player activePlayer = getConnection().getActivePlayer();
    		if (activePlayer.isLegionMember()) {
    			final Legion legion = activePlayer.getLegion();
    
    			if (charName != null) {
    				LegionService.getInstance().handleCharNameRequest(exOpcode, activePlayer, charName, newNickname, rank);
    			} else {
    				switch (exOpcode) {
    					/**
    					 * Refresh legion info *
    					 */
    					case 0x08:
    						sendPacket(new SM_LEGION_INFO(legion));
    						break;
    					/**
    					 * Edit announcements *
    					 */
    					case 0x09:
    						LegionService.getInstance().handleLegionRequest(exOpcode, activePlayer, announcement);
    						break;
    					/**
    					 * Change self introduction *
    					 */
    					case 0x0A:
    						LegionService.getInstance().handleLegionRequest(exOpcode, activePlayer, newSelfIntro);
    						break;
    					/**
    					 * Edit permissions *
    					 */
    					case 0x0D:
    						if (activePlayer.getLegionMember().isBrigadeGeneral()) {
    							LegionService.getInstance().changePermissions(legion, deputyPermission, centurionPermission, legionarPermission, volunteerPermission);
    						}
    						break;
    					/**
    					 * Change Legion description *
    					*/ 
    					case 0x11:
    						if (activePlayer.getLegionMember().isBrigadeGeneral())
    							LegionService.getInstance().setJoinDescription(activePlayer, joinDescription);
    						break;
    					/**
    					* Change Legion joinType *
    					*/ 
    					case 0x12:
    						if (activePlayer.getLegionMember().isBrigadeGeneral())
    							LegionService.getInstance().setJoinType(activePlayer, joinType);
    						break;
    					/**
    					* Change Legion minimal Join Level *
    					*/ 
    					case 0x13:
    						if (activePlayer.getLegionMember().isBrigadeGeneral())
    							LegionService.getInstance().setJoinMinLevel(activePlayer, minLevel);
    						break;
    					/**
    					* Legion accept recruit request *
    					*/ 
    					case 0x14:
    						if (activePlayer.getLegionMember().isBrigadeGeneral())							   
    							LegionService.getInstance().handleJoinRequestGiveAnswer(activePlayer, playerId, true);
    						break;					   
    					/**
    					* Legion deny recruit request *
    					*/ 
    					case 0x15:
    						if (activePlayer.getLegionMember().isBrigadeGeneral())							   
    							LegionService.getInstance().handleJoinRequestGiveAnswer(activePlayer, playerId, false);
    						break;				   
    					 /**
    					 * Misc. *
    					 */
    					default:
    						LegionService.getInstance().handleLegionRequest(exOpcode, activePlayer);
    						break;
    				}
    			}
    		} else {
    			switch (exOpcode) {
    				/**
    				 * Create a legion *
    				 */
    				case 0x00:
    					if (NameRestrictionService.isForbiddenWord(legionName)) {
    						PacketSendUtility.sendMessage(activePlayer, "You are trying to use a forbidden name. Choose another one!");
    					} else {
    						LegionService.getInstance().createLegion(activePlayer, legionName);
    					}
    					break;
    			}
    		}
    	}
    }
    А это серверный
    Код:
    public class SM_LEGION_EDIT extends AionServerPacket {
    
    	private int type;
    	private Legion legion;
    	private int unixTime;
    	private String announcement;
    
    	public SM_LEGION_EDIT(int type) {
    		this.type = type;
    	}
    
    	public SM_LEGION_EDIT(int type, Legion legion) {
    		this.type = type;
    		this.legion = legion;
    	}
    
    	public SM_LEGION_EDIT(int type, int unixTime) {
    		this.type = type;
    		this.unixTime = unixTime;
    	}
    
    	public SM_LEGION_EDIT(int type, int unixTime, String announcement) {
    		this.type = type;
    		this.announcement = announcement;
    		this.unixTime = unixTime;
    	}
    
    	@Override
    	protected void writeImpl(AionConnection con) {
    		writeC(type);
    		switch (type) {
    			/**
    			 * Change Legion Level *
    			 */
    			case 0x00:
    				writeC(legion.getLegionLevel());
    				break;
    			/**
    			 * Change Legion Rank *
    			 */
    			case 0x01:
    				writeD(legion.getLegionRank());
    				break;
    			/**
    			 * Change Legion Permissions *
    			 */
    			case 0x02:
    				writeH(legion.getDeputyPermission());
    				writeH(legion.getCenturionPermission());
    				writeH(legion.getLegionaryPermission());
    				writeH(legion.getVolunteerPermission());
    				break;
    			/**
    			 * Change Legion Contributions *
    			 */
    			case 0x03:
    				writeQ(legion.getContributionPoints()); // get Contributions
    				break;
    			case 0x04:
    				writeQ(legion.getLegionWarehouse().getKinah());
    				break;
    			/**
    			 * Change Legion Announcement *
    			 */
    			case 0x05:
    				writeS(announcement);
    				writeD(unixTime);
    				break;
    			/**
    			 * Disband Legion *
    			 */
    			case 0x06:
    				writeD(unixTime);
    				break;
    			/**
    			 * Recover Legion *
    			 */
    			case 0x07:
    				break;
    			/**
    			 * Refresh Legion Announcement? *
    			 */
    			case 0x08:
    				break;
    
    			case 0x0C:
    				writeS(legion.getLegionDiscription());
    				break;
    			
    			case 0x0D:
    				writeC(legion.getLegionJoinType());
    				break;
    			
    			case 0x0E:
    				writeH(legion.getMinLevel());
    				break;
    				  
    		}
    	}
    }
     
  2. Offline

    meridianblade Ефрейтор

    199
    19
    51
    Кредиты:
    $375,52
    Репутация:
    3
    Объява в SM_LEGION_INFO
     
  3. Offline

    meridianblade Ефрейтор

    199
    19
    51
    Кредиты:
    $375,52
    Репутация:
    3
    Такой пакет у меня нормально работает

    writeS(legion.getLegionName());
    writeC(legion.getLegionLevel());
    writeD(legion.getLegionRank());
    writeH(legion.getDeputyPermission());
    writeH(legion.getCenturionPermission());
    writeH(legion.getLegionaryPermission());
    writeH(legion.getVolunteerPermission());
    writeQ(legion.getContributionPoints());
    writeB(new byte[24]); //UNK but not a spacer ...
    writeS(legion.getLegionDiscription());
    writeC(legion.getLegionJoinType());
    writeH(legion.getMinLevel());

    /**
    * Get Announcements List From DB By Legion *
    */
    Map<Timestamp, String> announcementList = legion.getAnnouncementList().descendingMap();

    /**
    * Show max 7 announcements *
    */
    int i = 0;
    for (Timestamp unixTime : announcementList.keySet()) {
    writeS(announcementList.get(unixTime));
    writeD((int) (unixTime.getTime() / 1000));
    i++;
    if (i >= 7) {
    break;
    }
    }
     
    nokiafan1111 нравится это.
  4. TopicStarter Overlay
    Offline

    nokiafan1111 Ефрейтор

    331
    21
    51
    Кредиты:
    $329,63
    Репутация:
    2
    помогло) пасиб
     
  5. Offline

    akmal_92 Рядовой

    16
    0
    27
    Кредиты:
    $108,00
    Репутация:
    0
    Бомж хД