CreatureSay cleanup and improvements.
This commit is contained in:
		@@ -91,8 +91,7 @@ public class PolymorphingOnAttack extends AbstractNpcAI
 | 
			
		||||
				if (tmp.get(3) >= 0)
 | 
			
		||||
				{
 | 
			
		||||
					final NpcStringId npcString = MOBTEXTS[tmp.get(3)][getRandom(MOBTEXTS[tmp.get(3)].length)];
 | 
			
		||||
					npc.broadcastPacket(new CreatureSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getName(), npcString));
 | 
			
		||||
					
 | 
			
		||||
					npc.broadcastPacket(new CreatureSay(npc, ChatType.NPC_GENERAL, npcString));
 | 
			
		||||
				}
 | 
			
		||||
				npc.deleteMe();
 | 
			
		||||
				final Attackable newNpc = (Attackable) addSpawn(tmp.get(0), npc.getX(), npc.getY(), npc.getZ() + 10, npc.getHeading(), false, 0, true);
 | 
			
		||||
 
 | 
			
		||||
@@ -380,7 +380,7 @@ public class Race extends Event
 | 
			
		||||
	
 | 
			
		||||
	private void sendMessage(PlayerInstance player, String text)
 | 
			
		||||
	{
 | 
			
		||||
		player.sendPacket(new CreatureSay(_npc.getObjectId(), ChatType.MPCC_ROOM, _npc.getName(), text));
 | 
			
		||||
		player.sendPacket(new CreatureSay(_npc, ChatType.MPCC_ROOM, _npc.getName(), text));
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	private void showMenu(PlayerInstance player)
 | 
			
		||||
 
 | 
			
		||||
@@ -625,7 +625,7 @@ public class MerrySquashmas extends LongTimeEvent
 | 
			
		||||
	{
 | 
			
		||||
		if (Rnd.get(100) < 20)
 | 
			
		||||
		{
 | 
			
		||||
			npc.broadcastPacket(new CreatureSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getName(), _CHRONO_TEXT[Rnd.get(_CHRONO_TEXT.length)]));
 | 
			
		||||
			npc.broadcastPacket(new CreatureSay(npc, ChatType.NPC_GENERAL, npc.getName(), _CHRONO_TEXT[Rnd.get(_CHRONO_TEXT.length)]));
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
@@ -633,7 +633,7 @@ public class MerrySquashmas extends LongTimeEvent
 | 
			
		||||
	{
 | 
			
		||||
		if (Rnd.get(100) < 20)
 | 
			
		||||
		{
 | 
			
		||||
			npc.broadcastPacket(new CreatureSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getName(), _NOCHRONO_TEXT[Rnd.get(_NOCHRONO_TEXT.length)]));
 | 
			
		||||
			npc.broadcastPacket(new CreatureSay(npc, ChatType.NPC_GENERAL, npc.getName(), _NOCHRONO_TEXT[Rnd.get(_NOCHRONO_TEXT.length)]));
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
@@ -641,7 +641,7 @@ public class MerrySquashmas extends LongTimeEvent
 | 
			
		||||
	{
 | 
			
		||||
		if (Rnd.get(100) < 30)
 | 
			
		||||
		{
 | 
			
		||||
			npc.broadcastPacket(new CreatureSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getName(), _NECTAR_TEXT[Rnd.get(_NECTAR_TEXT.length)]));
 | 
			
		||||
			npc.broadcastPacket(new CreatureSay(npc, ChatType.NPC_GENERAL, npc.getName(), _NECTAR_TEXT[Rnd.get(_NECTAR_TEXT.length)]));
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
 
 | 
			
		||||
@@ -624,7 +624,7 @@ public class SquashEvent extends LongTimeEvent
 | 
			
		||||
	{
 | 
			
		||||
		if (Rnd.get(100) < 20)
 | 
			
		||||
		{
 | 
			
		||||
			npc.broadcastPacket(new CreatureSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getName(), _CHRONO_TEXT[Rnd.get(_CHRONO_TEXT.length)]));
 | 
			
		||||
			npc.broadcastPacket(new CreatureSay(npc, ChatType.NPC_GENERAL, npc.getName(), _CHRONO_TEXT[Rnd.get(_CHRONO_TEXT.length)]));
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
@@ -632,7 +632,7 @@ public class SquashEvent extends LongTimeEvent
 | 
			
		||||
	{
 | 
			
		||||
		if (Rnd.get(100) < 20)
 | 
			
		||||
		{
 | 
			
		||||
			npc.broadcastPacket(new CreatureSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getName(), _NOCHRONO_TEXT[Rnd.get(_NOCHRONO_TEXT.length)]));
 | 
			
		||||
			npc.broadcastPacket(new CreatureSay(npc, ChatType.NPC_GENERAL, npc.getName(), _NOCHRONO_TEXT[Rnd.get(_NOCHRONO_TEXT.length)]));
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
@@ -640,7 +640,7 @@ public class SquashEvent extends LongTimeEvent
 | 
			
		||||
	{
 | 
			
		||||
		if (Rnd.get(100) < 30)
 | 
			
		||||
		{
 | 
			
		||||
			npc.broadcastPacket(new CreatureSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getName(), _NECTAR_TEXT[Rnd.get(_NECTAR_TEXT.length)]));
 | 
			
		||||
			npc.broadcastPacket(new CreatureSay(npc, ChatType.NPC_GENERAL, npc.getName(), _NECTAR_TEXT[Rnd.get(_NECTAR_TEXT.length)]));
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
 
 | 
			
		||||
@@ -612,7 +612,7 @@ public class WatermelonNinja extends LongTimeEvent
 | 
			
		||||
	{
 | 
			
		||||
		if (Rnd.get(100) < 20)
 | 
			
		||||
		{
 | 
			
		||||
			npc.broadcastPacket(new CreatureSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getName(), _CHRONO_TEXT[Rnd.get(_CHRONO_TEXT.length)]));
 | 
			
		||||
			npc.broadcastPacket(new CreatureSay(npc, ChatType.NPC_GENERAL, npc.getName(), _CHRONO_TEXT[Rnd.get(_CHRONO_TEXT.length)]));
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
@@ -620,7 +620,7 @@ public class WatermelonNinja extends LongTimeEvent
 | 
			
		||||
	{
 | 
			
		||||
		if (Rnd.get(100) < 20)
 | 
			
		||||
		{
 | 
			
		||||
			npc.broadcastPacket(new CreatureSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getName(), _NOCHRONO_TEXT[Rnd.get(_NOCHRONO_TEXT.length)]));
 | 
			
		||||
			npc.broadcastPacket(new CreatureSay(npc, ChatType.NPC_GENERAL, npc.getName(), _NOCHRONO_TEXT[Rnd.get(_NOCHRONO_TEXT.length)]));
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
@@ -628,7 +628,7 @@ public class WatermelonNinja extends LongTimeEvent
 | 
			
		||||
	{
 | 
			
		||||
		if (Rnd.get(100) < 30)
 | 
			
		||||
		{
 | 
			
		||||
			npc.broadcastPacket(new CreatureSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getName(), _NECTAR_TEXT[Rnd.get(_NECTAR_TEXT.length)]));
 | 
			
		||||
			npc.broadcastPacket(new CreatureSay(npc, ChatType.NPC_GENERAL, npc.getName(), _NECTAR_TEXT[Rnd.get(_NECTAR_TEXT.length)]));
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
 
 | 
			
		||||
@@ -296,7 +296,7 @@ public class AdminAdmin implements IAdminCommandHandler
 | 
			
		||||
						sb.append(" ");
 | 
			
		||||
					}
 | 
			
		||||
					
 | 
			
		||||
					final CreatureSay cs = new CreatureSay(activeChar, ChatType.WORLD, sb.toString());
 | 
			
		||||
					final CreatureSay cs = new CreatureSay(activeChar, ChatType.WORLD, activeChar.getName(), sb.toString());
 | 
			
		||||
					World.getInstance().getPlayers().stream().filter(activeChar::isNotBlocked).forEach(cs::sendTo);
 | 
			
		||||
					break;
 | 
			
		||||
				}
 | 
			
		||||
 
 | 
			
		||||
@@ -113,7 +113,7 @@ public class AdminGmChat implements IAdminCommandHandler
 | 
			
		||||
				offset = 13;
 | 
			
		||||
			}
 | 
			
		||||
			text = command.substring(offset);
 | 
			
		||||
			final CreatureSay cs = new CreatureSay(0, ChatType.ALLIANCE, activeChar.getName(), text);
 | 
			
		||||
			final CreatureSay cs = new CreatureSay(null, ChatType.ALLIANCE, activeChar.getName(), text);
 | 
			
		||||
			AdminData.getInstance().broadcastToGMs(cs);
 | 
			
		||||
		}
 | 
			
		||||
		catch (StringIndexOutOfBoundsException e)
 | 
			
		||||
 
 | 
			
		||||
@@ -53,7 +53,7 @@ public class AdminTargetSay implements IAdminCommandHandler
 | 
			
		||||
				
 | 
			
		||||
				final String message = command.substring(16);
 | 
			
		||||
				final Creature target = (Creature) obj;
 | 
			
		||||
				target.broadcastPacket(new CreatureSay(target.getObjectId(), target.isPlayer() ? ChatType.GENERAL : ChatType.NPC_GENERAL, target.getName(), message));
 | 
			
		||||
				target.broadcastPacket(new CreatureSay(target, target.isPlayer() ? ChatType.GENERAL : ChatType.NPC_GENERAL, target.getName(), message));
 | 
			
		||||
			}
 | 
			
		||||
			catch (StringIndexOutOfBoundsException e)
 | 
			
		||||
			{
 | 
			
		||||
 
 | 
			
		||||
@@ -124,7 +124,7 @@ public class FindPvP implements IBypassHandler
 | 
			
		||||
				
 | 
			
		||||
				if (biggestAllyId == allyId)
 | 
			
		||||
				{
 | 
			
		||||
					player.sendPacket(new CreatureSay(0, ChatType.WHISPER, target.getName(), "Sorry, your clan/ally is outnumbering the place already so you can't move there."));
 | 
			
		||||
					player.sendPacket(new CreatureSay(null, ChatType.WHISPER, target.getName(), "Sorry, your clan/ally is outnumbering the place already so you can't move there."));
 | 
			
		||||
					return true;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
@@ -139,7 +139,7 @@ public class FindPvP implements IBypassHandler
 | 
			
		||||
		}
 | 
			
		||||
		else
 | 
			
		||||
		{
 | 
			
		||||
			player.sendPacket(new CreatureSay(0, ChatType.WHISPER, target.getName(), "Sorry, I can't find anyone in flag status right now."));
 | 
			
		||||
			player.sendPacket(new CreatureSay(null, ChatType.WHISPER, target.getName(), "Sorry, I can't find anyone in flag status right now."));
 | 
			
		||||
		}
 | 
			
		||||
		return false;
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
@@ -53,7 +53,7 @@ public class ChatAlliance implements IChatHandler
 | 
			
		||||
			activeChar.sendPacket(SystemMessageId.CHATTING_IS_CURRENTLY_PROHIBITED);
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		activeChar.getClan().broadcastToOnlineAllyMembers(new CreatureSay(activeChar.getObjectId(), type, activeChar.getName(), text));
 | 
			
		||||
		activeChar.getClan().broadcastToOnlineAllyMembers(new CreatureSay(activeChar, type, activeChar.getName(), text));
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
 
 | 
			
		||||
@@ -54,7 +54,7 @@ public class ChatClan implements IChatHandler
 | 
			
		||||
			activeChar.sendPacket(SystemMessageId.CHATTING_IS_CURRENTLY_PROHIBITED);
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		activeChar.getClan().broadcastCSToOnlineMembers(new CreatureSay(activeChar.getObjectId(), type, activeChar.getName(), text), activeChar);
 | 
			
		||||
		activeChar.getClan().broadcastCSToOnlineMembers(new CreatureSay(activeChar, type, activeChar.getName(), text), activeChar);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
 
 | 
			
		||||
@@ -87,8 +87,8 @@ public class ChatGeneral implements IChatHandler
 | 
			
		||||
				return;
 | 
			
		||||
			}
 | 
			
		||||
			
 | 
			
		||||
			final CreatureSay cs = new CreatureSay(activeChar.getObjectId(), type, activeChar.getAppearance().getVisibleName(), text);
 | 
			
		||||
			final CreatureSay csRandom = new CreatureSay(activeChar.getObjectId(), type, activeChar.getAppearance().getVisibleName(), ChatRandomizer.randomize(text));
 | 
			
		||||
			final CreatureSay cs = new CreatureSay(activeChar, type, activeChar.getAppearance().getVisibleName(), text);
 | 
			
		||||
			final CreatureSay csRandom = new CreatureSay(activeChar, type, activeChar.getAppearance().getVisibleName(), ChatRandomizer.randomize(text));
 | 
			
		||||
			World.getInstance().forEachVisibleObjectInRange(activeChar, PlayerInstance.class, 1250, player ->
 | 
			
		||||
			{
 | 
			
		||||
				if ((player != null) && !BlockList.isBlocked(player, activeChar))
 | 
			
		||||
 
 | 
			
		||||
@@ -62,7 +62,7 @@ public class ChatHeroVoice implements IChatHandler
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		final CreatureSay cs = new CreatureSay(activeChar.getObjectId(), type, activeChar.getName(), text);
 | 
			
		||||
		final CreatureSay cs = new CreatureSay(activeChar, type, activeChar.getName(), text);
 | 
			
		||||
		for (PlayerInstance player : World.getInstance().getPlayers())
 | 
			
		||||
		{
 | 
			
		||||
			if ((player != null) && !BlockList.isBlocked(player, activeChar))
 | 
			
		||||
 
 | 
			
		||||
@@ -54,7 +54,7 @@ public class ChatParty implements IChatHandler
 | 
			
		||||
			activeChar.sendPacket(SystemMessageId.CHATTING_IS_CURRENTLY_PROHIBITED);
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		activeChar.getParty().broadcastCreatureSay(new CreatureSay(activeChar.getObjectId(), type, activeChar.getName(), text), activeChar);
 | 
			
		||||
		activeChar.getParty().broadcastCreatureSay(new CreatureSay(activeChar, type, activeChar.getName(), text), activeChar);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
 
 | 
			
		||||
@@ -53,7 +53,7 @@ public class ChatPartyMatchRoom implements IChatHandler
 | 
			
		||||
				return;
 | 
			
		||||
			}
 | 
			
		||||
			
 | 
			
		||||
			final CreatureSay cs = new CreatureSay(activeChar.getObjectId(), type, activeChar.getName(), text);
 | 
			
		||||
			final CreatureSay cs = new CreatureSay(activeChar, type, activeChar.getName(), text);
 | 
			
		||||
			for (PlayerInstance _member : room.getMembers())
 | 
			
		||||
			{
 | 
			
		||||
				if (Config.FACTION_SYSTEM_ENABLED)
 | 
			
		||||
 
 | 
			
		||||
@@ -50,7 +50,7 @@ public class ChatPartyRoomAll implements IChatHandler
 | 
			
		||||
				activeChar.sendPacket(SystemMessageId.CHATTING_IS_CURRENTLY_PROHIBITED);
 | 
			
		||||
				return;
 | 
			
		||||
			}
 | 
			
		||||
			activeChar.getParty().getCommandChannel().broadcastCreatureSay(new CreatureSay(activeChar.getObjectId(), type, activeChar.getName(), text), activeChar);
 | 
			
		||||
			activeChar.getParty().getCommandChannel().broadcastCreatureSay(new CreatureSay(activeChar, type, activeChar.getName(), text), activeChar);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
 
 | 
			
		||||
@@ -50,7 +50,7 @@ public class ChatPartyRoomCommander implements IChatHandler
 | 
			
		||||
				activeChar.sendPacket(SystemMessageId.CHATTING_IS_CURRENTLY_PROHIBITED);
 | 
			
		||||
				return;
 | 
			
		||||
			}
 | 
			
		||||
			activeChar.getParty().getCommandChannel().broadcastCreatureSay(new CreatureSay(activeChar.getObjectId(), type, activeChar.getName(), text), activeChar);
 | 
			
		||||
			activeChar.getParty().getCommandChannel().broadcastCreatureSay(new CreatureSay(activeChar, type, activeChar.getName(), text), activeChar);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
 
 | 
			
		||||
@@ -58,7 +58,7 @@ public class ChatShout implements IChatHandler
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		final CreatureSay cs = new CreatureSay(activeChar.getObjectId(), type, activeChar.getName(), text);
 | 
			
		||||
		final CreatureSay cs = new CreatureSay(activeChar, type, activeChar.getName(), text);
 | 
			
		||||
		if (Config.DEFAULT_GLOBAL_CHAT.equalsIgnoreCase("on") || (Config.DEFAULT_GLOBAL_CHAT.equalsIgnoreCase("gm") && activeChar.canOverrideCond(PlayerCondOverride.CHAT_CONDITIONS)))
 | 
			
		||||
		{
 | 
			
		||||
			final int region = MapRegionManager.getInstance().getMapRegionLocId(activeChar);
 | 
			
		||||
 
 | 
			
		||||
@@ -58,7 +58,7 @@ public class ChatTrade implements IChatHandler
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		final CreatureSay cs = new CreatureSay(activeChar.getObjectId(), type, activeChar.getName(), text);
 | 
			
		||||
		final CreatureSay cs = new CreatureSay(activeChar, type, activeChar.getName(), text);
 | 
			
		||||
		if (Config.DEFAULT_TRADE_CHAT.equalsIgnoreCase("on") || (Config.DEFAULT_TRADE_CHAT.equalsIgnoreCase("gm") && activeChar.canOverrideCond(PlayerCondOverride.CHAT_CONDITIONS)))
 | 
			
		||||
		{
 | 
			
		||||
			final int region = MapRegionManager.getInstance().getMapRegionLocId(activeChar);
 | 
			
		||||
 
 | 
			
		||||
@@ -93,7 +93,7 @@ public class ChatWorld implements IChatHandler
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			
 | 
			
		||||
			final CreatureSay cs = new CreatureSay(activeChar, type, text);
 | 
			
		||||
			final CreatureSay cs = new CreatureSay(activeChar, type, activeChar.getName(), text);
 | 
			
		||||
			if (Config.FACTION_SYSTEM_ENABLED && Config.FACTION_SPECIFIC_CHAT)
 | 
			
		||||
			{
 | 
			
		||||
				if (activeChar.isGood())
 | 
			
		||||
 
 | 
			
		||||
@@ -52,7 +52,7 @@ public class GMChat implements ITelnetCommand
 | 
			
		||||
		{
 | 
			
		||||
			sb.append(str + " ");
 | 
			
		||||
		}
 | 
			
		||||
		AdminData.getInstance().broadcastToGMs(new CreatureSay(0, ChatType.ALLIANCE, "Telnet GM Broadcast", sb.toString()));
 | 
			
		||||
		AdminData.getInstance().broadcastToGMs(new CreatureSay(null, ChatType.ALLIANCE, "Telnet GM Broadcast", sb.toString()));
 | 
			
		||||
		return "GMChat sent!";
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -56,7 +56,7 @@ public class Msg implements ITelnetCommand
 | 
			
		||||
			{
 | 
			
		||||
				sb.append(args[i] + " ");
 | 
			
		||||
			}
 | 
			
		||||
			player.sendPacket(new CreatureSay(0, ChatType.WHISPER, "Telnet Priv", sb.toString()));
 | 
			
		||||
			player.sendPacket(new CreatureSay(null, ChatType.WHISPER, "Telnet Priv", sb.toString()));
 | 
			
		||||
			return "Announcement sent!";
 | 
			
		||||
		}
 | 
			
		||||
		return "Couldn't find player with such name.";
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user