CreatureSay cleanup and improvements.
This commit is contained in:
@@ -110,9 +110,7 @@ public class AnnouncementsTable
|
||||
{
|
||||
if (announce.isValid() && (announce.getType() == type))
|
||||
{
|
||||
player.sendPacket(new CreatureSay(0, //
|
||||
type == AnnouncementType.CRITICAL ? ChatType.CRITICAL_ANNOUNCE : ChatType.ANNOUNCEMENT, //
|
||||
player.getName(), announce.getContent()));
|
||||
player.sendPacket(new CreatureSay(null, type == AnnouncementType.CRITICAL ? ChatType.CRITICAL_ANNOUNCE : ChatType.ANNOUNCEMENT, player.getName(), announce.getContent()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -179,7 +179,7 @@ public class FakePlayerChatManager implements IXmlReader
|
||||
final Npc npc = spawn.getLastSpawn();
|
||||
if (npc != null)
|
||||
{
|
||||
player.sendPacket(new CreatureSay(npc, fpcName, ChatType.WHISPER, message));
|
||||
player.sendPacket(new CreatureSay(npc, ChatType.WHISPER, fpcName, message));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -339,7 +339,7 @@ public class PetitionManager
|
||||
|
||||
if ((currPetition.getPetitioner() != null) && (currPetition.getPetitioner().getObjectId() == player.getObjectId()))
|
||||
{
|
||||
cs = new CreatureSay(player.getObjectId(), ChatType.PETITION_PLAYER, player.getName(), messageText);
|
||||
cs = new CreatureSay(player, ChatType.PETITION_PLAYER, player.getName(), messageText);
|
||||
currPetition.addLogMessage(cs);
|
||||
|
||||
currPetition.sendResponderPacket(cs);
|
||||
@@ -349,7 +349,7 @@ public class PetitionManager
|
||||
|
||||
if ((currPetition.getResponder() != null) && (currPetition.getResponder().getObjectId() == player.getObjectId()))
|
||||
{
|
||||
cs = new CreatureSay(player.getObjectId(), ChatType.PETITION_GM, player.getName(), messageText);
|
||||
cs = new CreatureSay(player, ChatType.PETITION_GM, player.getName(), messageText);
|
||||
currPetition.addLogMessage(cs);
|
||||
|
||||
currPetition.sendResponderPacket(cs);
|
||||
@@ -423,7 +423,7 @@ public class PetitionManager
|
||||
|
||||
// Notify all GMs that a new petition has been submitted.
|
||||
final String msgContent = petitioner.getName() + " has submitted a new petition."; // (ID: " + newPetitionId + ").";
|
||||
AdminData.getInstance().broadcastToGMs(new CreatureSay(petitioner.getObjectId(), ChatType.HERO_VOICE, "Petition System", msgContent));
|
||||
AdminData.getInstance().broadcastToGMs(new CreatureSay(petitioner, ChatType.HERO_VOICE, "Petition System", msgContent));
|
||||
|
||||
return newPetitionId;
|
||||
}
|
||||
|
@@ -222,7 +222,7 @@ public class Attackable extends Npc
|
||||
_commandChannelTimer = new CommandChannelTimer(this);
|
||||
_commandChannelLastAttack = System.currentTimeMillis();
|
||||
ThreadPool.schedule(_commandChannelTimer, 10000); // check for last attack
|
||||
_firstCommandChannelAttacked.broadcastPacket(new CreatureSay(0, ChatType.PARTYROOM_ALL, "", "You have looting rights!")); // TODO: retail msg
|
||||
_firstCommandChannelAttacked.broadcastPacket(new CreatureSay(null, ChatType.PARTYROOM_ALL, "", "You have looting rights!")); // TODO: retail msg
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -185,7 +185,7 @@ public abstract class VoteSystem implements Runnable
|
||||
|
||||
private void announce(String msg)
|
||||
{
|
||||
final CreatureSay cs = new CreatureSay(0, ChatType.CRITICAL_ANNOUNCE, "", msg);
|
||||
final CreatureSay cs = new CreatureSay(null, ChatType.CRITICAL_ANNOUNCE, "", msg);
|
||||
Broadcast.toAllOnlinePlayers(cs);
|
||||
}
|
||||
|
||||
|
@@ -464,7 +464,7 @@ public class EnterWorld implements IClientIncomingPacket
|
||||
|
||||
if ((Config.SERVER_RESTART_SCHEDULE_ENABLED) && (Config.SERVER_RESTART_SCHEDULE_MESSAGE))
|
||||
{
|
||||
player.sendPacket(new CreatureSay(2, ChatType.BATTLEFIELD, "[SERVER]", "Next restart is scheduled at " + ServerRestartManager.getInstance().getNextRestartTime() + "."));
|
||||
player.sendPacket(new CreatureSay(null, ChatType.BATTLEFIELD, "[SERVER]", "Next restart is scheduled at " + ServerRestartManager.getInstance().getNextRestartTime() + "."));
|
||||
}
|
||||
|
||||
if (showClanNotice)
|
||||
|
@@ -80,7 +80,7 @@ public class RequestPetitionCancel implements IClientIncomingPacket
|
||||
|
||||
// Notify all GMs that the player's pending petition has been cancelled.
|
||||
final String msgContent = player.getName() + " has canceled a pending petition.";
|
||||
AdminData.getInstance().broadcastToGMs(new CreatureSay(player.getObjectId(), ChatType.HERO_VOICE, "Petition System", msgContent));
|
||||
AdminData.getInstance().broadcastToGMs(new CreatureSay(player, ChatType.HERO_VOICE, "Petition System", msgContent));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@@ -22,7 +22,7 @@ import java.util.List;
|
||||
import org.l2jmobius.commons.network.PacketWriter;
|
||||
import org.l2jmobius.gameserver.enums.ChatType;
|
||||
import org.l2jmobius.gameserver.instancemanager.MentorManager;
|
||||
import org.l2jmobius.gameserver.model.actor.Npc;
|
||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
import org.l2jmobius.gameserver.network.NpcStringId;
|
||||
import org.l2jmobius.gameserver.network.OutgoingPackets;
|
||||
@@ -30,30 +30,29 @@ import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||
|
||||
public class CreatureSay implements IClientOutgoingPacket
|
||||
{
|
||||
private final int _objectId;
|
||||
private final ChatType _textType;
|
||||
private String _charName = null;
|
||||
private int _charId = 0;
|
||||
private final Creature _sender;
|
||||
private final ChatType _chatType;
|
||||
private String _senderName = null;
|
||||
private String _text = null;
|
||||
private int _npcString = -1;
|
||||
private int _charId = 0;
|
||||
private int _messageId = -1;
|
||||
private int _mask;
|
||||
private int _charLevel = -1;
|
||||
private List<String> _parameters;
|
||||
|
||||
/**
|
||||
* @param sender
|
||||
* @param receiver
|
||||
* @param name
|
||||
* @param messageType
|
||||
* @param chatType
|
||||
* @param text
|
||||
*/
|
||||
public CreatureSay(PlayerInstance sender, PlayerInstance receiver, String name, ChatType messageType, String text)
|
||||
public CreatureSay(PlayerInstance sender, PlayerInstance receiver, String name, ChatType chatType, String text)
|
||||
{
|
||||
_objectId = sender.getObjectId();
|
||||
_charName = name;
|
||||
_charLevel = sender.getLevel();
|
||||
_textType = messageType;
|
||||
_sender = sender;
|
||||
_senderName = name;
|
||||
_chatType = chatType;
|
||||
_text = text;
|
||||
|
||||
if (receiver != null)
|
||||
{
|
||||
if (receiver.getFriendList().contains(sender.getObjectId()))
|
||||
@@ -81,66 +80,27 @@ public class CreatureSay implements IClientOutgoingPacket
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Used by fake players.
|
||||
* @param sender
|
||||
* @param name
|
||||
* @param messageType
|
||||
* @param text
|
||||
*/
|
||||
public CreatureSay(Npc sender, String name, ChatType messageType, String text)
|
||||
public CreatureSay(Creature sender, ChatType chatType, String senderName, String text)
|
||||
{
|
||||
_objectId = sender.getObjectId();
|
||||
_charName = name;
|
||||
_charLevel = sender.getLevel();
|
||||
_textType = messageType;
|
||||
_sender = sender;
|
||||
_chatType = chatType;
|
||||
_senderName = senderName;
|
||||
_text = text;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param objectId
|
||||
* @param messageType
|
||||
* @param charName
|
||||
* @param text
|
||||
*/
|
||||
public CreatureSay(int objectId, ChatType messageType, String charName, String text)
|
||||
public CreatureSay(Creature sender, ChatType chatType, NpcStringId npcStringId)
|
||||
{
|
||||
_objectId = objectId;
|
||||
_textType = messageType;
|
||||
_charName = charName;
|
||||
_text = text;
|
||||
_sender = sender;
|
||||
_chatType = chatType;
|
||||
_messageId = npcStringId.getId();
|
||||
}
|
||||
|
||||
public CreatureSay(PlayerInstance player, ChatType messageType, String text)
|
||||
public CreatureSay(ChatType chatType, int charId, SystemMessageId systemMessageId)
|
||||
{
|
||||
_objectId = player.getObjectId();
|
||||
_textType = messageType;
|
||||
_charName = player.getAppearance().getVisibleName();
|
||||
_text = text;
|
||||
}
|
||||
|
||||
public CreatureSay(int objectId, ChatType messageType, int charId, NpcStringId npcString)
|
||||
{
|
||||
_objectId = objectId;
|
||||
_textType = messageType;
|
||||
_sender = null;
|
||||
_chatType = chatType;
|
||||
_charId = charId;
|
||||
_npcString = npcString.getId();
|
||||
}
|
||||
|
||||
public CreatureSay(int objectId, ChatType messageType, String charName, NpcStringId npcString)
|
||||
{
|
||||
_objectId = objectId;
|
||||
_textType = messageType;
|
||||
_charName = charName;
|
||||
_npcString = npcString.getId();
|
||||
}
|
||||
|
||||
public CreatureSay(int objectId, ChatType messageType, int charId, SystemMessageId sysString)
|
||||
{
|
||||
_objectId = objectId;
|
||||
_textType = messageType;
|
||||
_charId = charId;
|
||||
_npcString = sysString.getId();
|
||||
_messageId = systemMessageId.getId();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -161,26 +121,26 @@ public class CreatureSay implements IClientOutgoingPacket
|
||||
{
|
||||
OutgoingPackets.SAY2.writeId(packet);
|
||||
|
||||
packet.writeD(_objectId);
|
||||
packet.writeD(_textType.getClientId());
|
||||
if (_charName != null)
|
||||
packet.writeD(_sender == null ? 0 : _sender.getObjectId());
|
||||
packet.writeD(_chatType.getClientId());
|
||||
if (_senderName != null)
|
||||
{
|
||||
packet.writeS(_charName);
|
||||
packet.writeS(_senderName);
|
||||
}
|
||||
else
|
||||
{
|
||||
packet.writeD(_charId);
|
||||
}
|
||||
packet.writeD(_npcString); // High Five NPCString ID
|
||||
packet.writeD(_messageId); // High Five NPCString ID
|
||||
if (_text != null)
|
||||
{
|
||||
packet.writeS(_text);
|
||||
if ((_charLevel > 0) && (_textType == ChatType.WHISPER))
|
||||
if ((_sender != null) && (_sender.isPlayer() || _sender.isFakePlayer()) && (_chatType == ChatType.WHISPER))
|
||||
{
|
||||
packet.writeC(_mask);
|
||||
if ((_mask & 0x10) == 0)
|
||||
{
|
||||
packet.writeC(_charLevel);
|
||||
packet.writeC(_sender.getLevel());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -199,7 +159,7 @@ public class CreatureSay implements IClientOutgoingPacket
|
||||
{
|
||||
if (player != null)
|
||||
{
|
||||
player.broadcastSnoop(_textType, _charName, _text);
|
||||
player.broadcastSnoop(_chatType, _senderName, _text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -184,7 +184,7 @@ public class Broadcast
|
||||
|
||||
public static void toAllOnlinePlayers(String text, boolean isCritical)
|
||||
{
|
||||
toAllOnlinePlayers(new CreatureSay(0, isCritical ? ChatType.CRITICAL_ANNOUNCE : ChatType.ANNOUNCEMENT, "", text));
|
||||
toAllOnlinePlayers(new CreatureSay(null, isCritical ? ChatType.CRITICAL_ANNOUNCE : ChatType.ANNOUNCEMENT, "", text));
|
||||
}
|
||||
|
||||
public static void toAllOnlinePlayersOnScreen(String text)
|
||||
|
@@ -41,7 +41,7 @@ public class BuilderUtil
|
||||
{
|
||||
if (Config.GM_STARTUP_BUILDER_HIDE)
|
||||
{
|
||||
player.sendPacket(new CreatureSay(0, ChatType.GENERAL, "SYS", message));
|
||||
player.sendPacket(new CreatureSay(null, ChatType.GENERAL, "SYS", message));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -56,7 +56,7 @@ public class BuilderUtil
|
||||
*/
|
||||
public static void sendHtmlMessage(PlayerInstance player, String message)
|
||||
{
|
||||
player.sendPacket(new CreatureSay(0, ChatType.GENERAL, "HTML", message));
|
||||
player.sendPacket(new CreatureSay(null, ChatType.GENERAL, "HTML", message));
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user