테스트

aion-server 4.8

Gitteol
최고관리자 · 1 · 💬 0 클론/새로받기
 4.8 61f661d · 1 commits 새로받기(Pull)
game-server/src/com/aionemu/gameserver/network/aion/serverpackets/SM_MESSAGE.java
package com.aionemu.gameserver.network.aion.serverpackets;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.aionemu.gameserver.configs.main.CustomConfig;
import com.aionemu.gameserver.model.ChatType;
import com.aionemu.gameserver.model.gameobjects.Creature;
import com.aionemu.gameserver.model.gameobjects.Npc;
import com.aionemu.gameserver.model.gameobjects.player.Player;
import com.aionemu.gameserver.network.aion.AionConnection;
import com.aionemu.gameserver.network.aion.AionServerPacket;
import com.aionemu.gameserver.skillengine.effect.AbnormalState;

/**
 * Message [chat, etc]
 * 
 * @author -Nemesiss-, Sweetkr, Neon
 */
public class SM_MESSAGE extends AionServerPacket {

	static final Logger log = LoggerFactory.getLogger(SM_MESSAGE.class);

	/**
	 * Maximum valid message length for a single chat message packet.<br>
	 * The client can't handle more than 4000 chars in one packet.<br>
	 * 4001+ disables all further client chat processing, ~4500 triggers send log error.
	 */
	public static final int MESSAGE_SIZE_HARDCAP = 4000;
	/**
	 * Maximum number of characters the client will display from a single chat message packet. Tested with a 4.8 client.
	 */
	public static final int MESSAGE_SIZE_LIMIT = 1022;

	/**
	 * ID of the object that is saying something or <tt>null</tt>.
	 */
	private int senderObjectId;

	/**
	 * Message
	 */
	private String message;

	/**
	 * Name of the sender
	 */
	private String senderName;

	/**
	 * Filter that the client will apply for the message.<br>
	 * If the readers race does not match the senders race, he will receive an obfuscated message.<br>
	 * 0: all, 1: elyos, 2: asmodian
	 */
	private byte senderRace;

	/**
	 * Chat type
	 */
	private ChatType chatType;

	/**
	 * Sender coordinates
	 */
	private float x;
	private float y;
	private float z;

	/**
	 * Constructs new <tt>SM_MESSAGE</tt> packet.
	 * 
	 * @param sender
	 *          player who sent the message
	 * @param message
	 *          actual message
	 * @param chatType
	 *          what chat type should be used
	 */
	public SM_MESSAGE(Player sender, String message, ChatType chatType) {
		this(sender, sender.getEffectController().isAbnormalSet(AbnormalState.HIDE) ? 0 : sender.getObjectId(), sender.getName(true), message, chatType);
	}

	/**
	 * Constructs new <tt>SM_MESSAGE</tt> packet.
	 * 
	 * @param sender
	 *          npc who sent the message
	 * @param message
	 *          actual message
	 * @param chatType
	 *          what chat type should be used
	 */
	public SM_MESSAGE(Npc sender, String message, ChatType chatType) {
		this(sender, sender.getObjectId(), sender.getName(), message, chatType);
	}

	/**
	 * Manual creation of chat message.
	 * 
	 * @param senderObjectId
	 *          can be 0 for system message (like announcements)
	 * @param senderName
	 *          if the client knows the senderObjectId, it will automatically display the objects name, otherwise this senderName will be shown (system
	 *          chats never show any sender name though)
	 * @param message
	 *          actual message
	 * @param chatType
	 *          what chat type should be used
	 */
	public SM_MESSAGE(int senderObjectId, String senderName, String message, ChatType chatType) {
		this(null, senderObjectId, senderName, message, chatType);
	}

	private SM_MESSAGE(Creature sender, int senderObjectId, String senderName, String message, ChatType chatType) {
		if (message.length() > MESSAGE_SIZE_LIMIT) {
			log.warn("Exceeded maximum string size for packet SM_MESSAGE.\nSize: " + message.length() + "\nMessage: " + message);
			if (message.length() > MESSAGE_SIZE_HARDCAP)
				message = message.substring(0, MESSAGE_SIZE_HARDCAP); // shorten message to avoid send log error
		}
		if (sender != null) {
			if (sender instanceof Player && !chatType.isSysMsg() && !CustomConfig.SPEAKING_BETWEEN_FACTIONS && !((Player) sender).isStaff()) {
				this.senderRace = (byte) (((Player) sender).getRace().getRaceId() + 1);
			}
			this.x = sender.getX();
			this.y = sender.getY();
			this.z = sender.getZ();
		}
		this.senderObjectId = senderObjectId;
		this.senderName = senderName;
		this.message = message;
		this.chatType = chatType;
	}

	@Override
	protected void writeImpl(AionConnection con) {
		Player activePlayer = con.getActivePlayer();
		if (activePlayer == null)
			return;
		writeC(chatType.getId());
		writeC(activePlayer.isStaff() ? 0 : senderRace);
		writeD(senderObjectId);
		writeS(senderName);
		writeS(message);
		if (chatType == ChatType.SHOUT) {
			writeF(x);
			writeF(y);
			writeF(z);
		}
	}
}

📎 첨부파일

댓글 작성 권한이 없습니다.
🏆 포인트 랭킹 TOP 10
순위 닉네임 포인트
1 no_profile 타키야겐지쪽지보내기 자기소개 아이디로 검색 전체게시물 102,949
2 no_profile 동가리쪽지보내기 자기소개 아이디로 검색 전체게시물 63,733
3 no_profile 라프텔쪽지보내기 자기소개 아이디로 검색 전체게시물 51,771
4 no_profile 불멸의행복쪽지보내기 자기소개 아이디로 검색 전체게시물 36,923
5 서번트쪽지보내기 자기소개 아이디로 검색 전체게시물 35,011
6 no_profile 닥터스쪽지보내기 자기소개 아이디로 검색 전체게시물 29,470
7 no_profile 검은고양이쪽지보내기 자기소개 아이디로 검색 전체게시물 29,077
8 no_profile Revolution쪽지보내기 자기소개 아이디로 검색 전체게시물 28,199
9 no_profile 보거스쪽지보내기 자기소개 아이디로 검색 전체게시물 26,731
10 no_profile 호롤롤로쪽지보내기 자기소개 아이디로 검색 전체게시물 17,020
알림 0