Fix duplicate "... entered battle" messages

This commit is contained in:
Stephen Seo 2018-10-18 13:43:26 +09:00
parent 0a26eee53a
commit 967fed3164

View file

@ -191,34 +191,37 @@ public class Battle
} }
} }
for(Combatant c : this.sideA.values()) if(isServer)
{ {
if(c.entityInfo != null) for(Combatant c : this.sideA.values())
{ {
sendMessageToAllPlayers(PacketBattleMessage.MessageType.ENTERED, c.entity.getEntityId(), 0, id, c.entityInfo.category); if(c.entityInfo != null)
{
sendMessageToAllPlayers(PacketBattleMessage.MessageType.ENTERED, c.entity.getEntityId(), 0, id, c.entityInfo.category);
}
else if(c.entity instanceof EntityPlayer)
{
sendMessageToAllPlayers(PacketBattleMessage.MessageType.ENTERED, c.entity.getEntityId(), 0, id, "player");
}
else
{
sendMessageToAllPlayers(PacketBattleMessage.MessageType.ENTERED, c.entity.getEntityId(), 0, id);
}
} }
else if(c.entity instanceof EntityPlayer) for(Combatant c : this.sideB.values())
{ {
sendMessageToAllPlayers(PacketBattleMessage.MessageType.ENTERED, c.entity.getEntityId(), 0, id, "player"); if(c.entityInfo != null)
} {
else sendMessageToAllPlayers(PacketBattleMessage.MessageType.ENTERED, c.entity.getEntityId(), 0, id, c.entityInfo.category);
{ }
sendMessageToAllPlayers(PacketBattleMessage.MessageType.ENTERED, c.entity.getEntityId(), 0, id); else if(c.entity instanceof EntityPlayer)
} {
} sendMessageToAllPlayers(PacketBattleMessage.MessageType.ENTERED, c.entity.getEntityId(), 0, id, "player");
for(Combatant c : this.sideB.values()) }
{ else
if(c.entityInfo != null) {
{ sendMessageToAllPlayers(PacketBattleMessage.MessageType.ENTERED, c.entity.getEntityId(), 0, id);
sendMessageToAllPlayers(PacketBattleMessage.MessageType.ENTERED, c.entity.getEntityId(), 0, id, c.entityInfo.category); }
}
else if(c.entity instanceof EntityPlayer)
{
sendMessageToAllPlayers(PacketBattleMessage.MessageType.ENTERED, c.entity.getEntityId(), 0, id, "player");
}
else
{
sendMessageToAllPlayers(PacketBattleMessage.MessageType.ENTERED, c.entity.getEntityId(), 0, id);
} }
} }
@ -299,17 +302,20 @@ public class Battle
newCombatant.yaw = e.rotationYaw; newCombatant.yaw = e.rotationYaw;
newCombatant.pitch = e.rotationPitch; newCombatant.pitch = e.rotationPitch;
} }
if(newCombatant.entityInfo != null) if(isServer)
{ {
sendMessageToAllPlayers(PacketBattleMessage.MessageType.ENTERED, newCombatant.entity.getEntityId(), 0, id, newCombatant.entityInfo.category); if(newCombatant.entityInfo != null)
} {
else if(newCombatant.entity instanceof EntityPlayer) sendMessageToAllPlayers(PacketBattleMessage.MessageType.ENTERED, newCombatant.entity.getEntityId(), 0, id, newCombatant.entityInfo.category);
{ }
sendMessageToAllPlayers(PacketBattleMessage.MessageType.ENTERED, newCombatant.entity.getEntityId(), 0, id, "player"); else if(newCombatant.entity instanceof EntityPlayer)
} {
else sendMessageToAllPlayers(PacketBattleMessage.MessageType.ENTERED, newCombatant.entity.getEntityId(), 0, id, "player");
{ }
sendMessageToAllPlayers(PacketBattleMessage.MessageType.ENTERED, newCombatant.entity.getEntityId(), 0, id); else
{
sendMessageToAllPlayers(PacketBattleMessage.MessageType.ENTERED, newCombatant.entity.getEntityId(), 0, id);
}
} }
notifyPlayersBattleInfo(); notifyPlayersBattleInfo();
} }
@ -352,17 +358,20 @@ public class Battle
newCombatant.yaw = e.rotationYaw; newCombatant.yaw = e.rotationYaw;
newCombatant.pitch = e.rotationPitch; newCombatant.pitch = e.rotationPitch;
} }
if(newCombatant.entityInfo != null) if(isServer)
{ {
sendMessageToAllPlayers(PacketBattleMessage.MessageType.ENTERED, newCombatant.entity.getEntityId(), 0, id, newCombatant.entityInfo.category); if(newCombatant.entityInfo != null)
} {
else if(newCombatant.entity instanceof EntityPlayer) sendMessageToAllPlayers(PacketBattleMessage.MessageType.ENTERED, newCombatant.entity.getEntityId(), 0, id, newCombatant.entityInfo.category);
{ }
sendMessageToAllPlayers(PacketBattleMessage.MessageType.ENTERED, newCombatant.entity.getEntityId(), 0, id, "player"); else if(newCombatant.entity instanceof EntityPlayer)
} {
else sendMessageToAllPlayers(PacketBattleMessage.MessageType.ENTERED, newCombatant.entity.getEntityId(), 0, id, "player");
{ }
sendMessageToAllPlayers(PacketBattleMessage.MessageType.ENTERED, newCombatant.entity.getEntityId(), 0, id); else
{
sendMessageToAllPlayers(PacketBattleMessage.MessageType.ENTERED, newCombatant.entity.getEntityId(), 0, id);
}
} }
notifyPlayersBattleInfo(); notifyPlayersBattleInfo();
} }