Commit f1d3b14e by Jonathan Thomas

Additional regressions caused by switching from UUID to player's display name…

Additional regressions caused by switching from UUID to player's display name (nick). Also, setting "born" and "death" timestamps, and no longer deleting chat data.
parent d71248da
Pipeline #12985 passed with stages
in 2 minutes 1 second
...@@ -16,6 +16,7 @@ All notable changes to **CreatureChat** are documented in this file. The format ...@@ -16,6 +16,7 @@ All notable changes to **CreatureChat** are documented in this file. The format
### Changed ### Changed
- Entity chat data now separates messages and friendship by player and includes timestamps - Entity chat data now separates messages and friendship by player and includes timestamps
- Data is no longer deleted on entity death, and instead a "death" timestamp is recorded
- Removed "pirate" speaking style and a few <non-response> outputs - Removed "pirate" speaking style and a few <non-response> outputs
- Passive entities no longer emit damage particles when attacking, they emit custom attack particles - Passive entities no longer emit damage particles when attacking, they emit custom attack particles
- Protect now auto sets friendship to 1 (if <= 0), to prevent entity from attacking and protecting at the same time - Protect now auto sets friendship to 1 (if <= 0), to prevent entity from attacking and protecting at the same time
......
...@@ -114,7 +114,7 @@ public class ClientPackets { ...@@ -114,7 +114,7 @@ public class ClientPackets {
MobEntity entity = ClientEntityFinder.getEntityByUUID(client.world, entityId); MobEntity entity = ClientEntityFinder.getEntityByUUID(client.world, entityId);
if (entity != null) { if (entity != null) {
ChatDataManager chatDataManager = ChatDataManager.getClientInstance(); ChatDataManager chatDataManager = ChatDataManager.getClientInstance();
EntityChatData chatData = chatDataManager.getOrCreateChatData(entity.getUuidAsString(), playerId.toString()); EntityChatData chatData = chatDataManager.getOrCreateChatData(entity.getUuidAsString(), playerName);
if (!message.isEmpty()) { if (!message.isEmpty()) {
chatData.currentMessage = message; chatData.currentMessage = message;
} }
......
...@@ -479,7 +479,7 @@ public class BubbleRenderer { ...@@ -479,7 +479,7 @@ public class BubbleRenderer {
EntityChatData chatData = null; EntityChatData chatData = null;
PlayerData playerData = null; PlayerData playerData = null;
if (entity instanceof MobEntity) { if (entity instanceof MobEntity) {
chatData = ChatDataManager.getClientInstance().getOrCreateChatData(entity.getUuidAsString(), player.getUuidAsString()); chatData = ChatDataManager.getClientInstance().getOrCreateChatData(entity.getUuidAsString(), player.getDisplayName().getString());
playerData = chatData.getPlayerData(player.getDisplayName().getString()); playerData = chatData.getPlayerData(player.getDisplayName().getString());
} else if (entity instanceof PlayerEntity) { } else if (entity instanceof PlayerEntity) {
chatData = PlayerMessageManager.getMessage(entity.getUuid()); chatData = PlayerMessageManager.getMessage(entity.getUuid());
......
...@@ -120,7 +120,7 @@ public class ClickHandler { ...@@ -120,7 +120,7 @@ public class ClickHandler {
MobEntity closestEntity = ClientEntityFinder.getEntityByUUID(client.world, closestEntityUUID); MobEntity closestEntity = ClientEntityFinder.getEntityByUUID(client.world, closestEntityUUID);
if (closestEntity != null) { if (closestEntity != null) {
// Look-up conversation // Look-up conversation
EntityChatData chatData = ChatDataManager.getClientInstance().getOrCreateChatData(closestEntityUUID.toString(), player.getUuidAsString()); EntityChatData chatData = ChatDataManager.getClientInstance().getOrCreateChatData(closestEntityUUID.toString(), player.getDisplayName().getString());
// Determine area clicked inside chat bubble (top, left, right) // Determine area clicked inside chat bubble (top, left, right)
String hitRegion = determineHitRegion(closestHitResult.get(), closestBubbleData.position, camera, closestBubbleData.height); String hitRegion = determineHitRegion(closestHitResult.get(), closestBubbleData.position, camera, closestBubbleData.height);
......
...@@ -73,8 +73,8 @@ public class ChatDataManager { ...@@ -73,8 +73,8 @@ public class ChatDataManager {
} }
// Retrieve chat data for a specific entity, or create it if it doesn't exist // Retrieve chat data for a specific entity, or create it if it doesn't exist
public EntityChatData getOrCreateChatData(String entityId, String playerId) { public EntityChatData getOrCreateChatData(String entityId, String playerName) {
return entityChatDataMap.computeIfAbsent(entityId, k -> new EntityChatData(entityId, playerId)); return entityChatDataMap.computeIfAbsent(entityId, k -> new EntityChatData(entityId, playerName));
} }
// Update the UUID in the map (i.e. bucketed entity and then released, changes their UUID) // Update the UUID in the map (i.e. bucketed entity and then released, changes their UUID)
......
...@@ -51,6 +51,8 @@ public class EntityChatData { ...@@ -51,6 +51,8 @@ public class EntityChatData {
public ChatDataManager.ChatSender sender; public ChatDataManager.ChatSender sender;
public int auto_generated; public int auto_generated;
public List<ChatMessage> previousMessages; public List<ChatMessage> previousMessages;
public Long born;
public Long death;
@SerializedName("playerId") @SerializedName("playerId")
@Expose(serialize = false) @Expose(serialize = false)
...@@ -63,11 +65,11 @@ public class EntityChatData { ...@@ -63,11 +65,11 @@ public class EntityChatData {
// The map to store data for each player interacting with this entity // The map to store data for each player interacting with this entity
public Map<String, PlayerData> players; public Map<String, PlayerData> players;
public EntityChatData(String entityId, String playerId) { public EntityChatData(String entityId, String playerName) {
this.entityId = entityId; this.entityId = entityId;
this.players = new HashMap<>(); this.players = new HashMap<>();
if (!playerId.isEmpty()) { if (!playerName.isEmpty()) {
this.players.put(playerId, new PlayerData()); this.players.put(playerName, new PlayerData());
} }
this.currentMessage = ""; this.currentMessage = "";
this.currentLineNumber = 0; this.currentLineNumber = 0;
...@@ -76,6 +78,7 @@ public class EntityChatData { ...@@ -76,6 +78,7 @@ public class EntityChatData {
this.sender = ChatDataManager.ChatSender.USER; this.sender = ChatDataManager.ChatSender.USER;
this.auto_generated = 0; this.auto_generated = 0;
this.previousMessages = new ArrayList<>(); this.previousMessages = new ArrayList<>();
this.born = System.currentTimeMillis();;
// Old, unused migrated properties // Old, unused migrated properties
this.legacyPlayerId = null; this.legacyPlayerId = null;
...@@ -106,6 +109,9 @@ public class EntityChatData { ...@@ -106,6 +109,9 @@ public class EntityChatData {
} }
} }
blankPlayerData.friendship = this.legacyFriendship; blankPlayerData.friendship = this.legacyFriendship;
if (this.born == null) {
this.born = System.currentTimeMillis();;
}
// Clean up old player data // Clean up old player data
this.legacyPlayerId = null; this.legacyPlayerId = null;
......
...@@ -71,7 +71,7 @@ public class LeadPlayerGoal extends PlayerBaseGoal { ...@@ -71,7 +71,7 @@ public class LeadPlayerGoal extends PlayerBaseGoal {
String arrivedMessage = "<You have arrived at your destination>"; String arrivedMessage = "<You have arrived at your destination>";
ChatDataManager chatDataManager = ChatDataManager.getServerInstance(); ChatDataManager chatDataManager = ChatDataManager.getServerInstance();
EntityChatData chatData = chatDataManager.getOrCreateChatData(this.entity.getUuidAsString(), this.targetEntity.getUuidAsString()); EntityChatData chatData = chatDataManager.getOrCreateChatData(this.entity.getUuidAsString(), this.targetEntity.getDisplayName().getString());
if (!chatData.characterSheet.isEmpty() && chatData.auto_generated < chatDataManager.MAX_AUTOGENERATE_RESPONSES) { if (!chatData.characterSheet.isEmpty() && chatData.auto_generated < chatDataManager.MAX_AUTOGENERATE_RESPONSES) {
ServerPackets.generate_chat("N/A", chatData, (ServerPlayerEntity) this.targetEntity, this.entity, arrivedMessage, true); ServerPackets.generate_chat("N/A", chatData, (ServerPlayerEntity) this.targetEntity, this.entity, arrivedMessage, true);
} }
......
...@@ -25,7 +25,7 @@ public class MixinLivingEntity { ...@@ -25,7 +25,7 @@ public class MixinLivingEntity {
private EntityChatData getChatData(LivingEntity entity, PlayerEntity player) { private EntityChatData getChatData(LivingEntity entity, PlayerEntity player) {
ChatDataManager chatDataManager = ChatDataManager.getServerInstance(); ChatDataManager chatDataManager = ChatDataManager.getServerInstance();
return chatDataManager.getOrCreateChatData(entity.getUuidAsString(), player.getUuidAsString()); return chatDataManager.getOrCreateChatData(entity.getUuidAsString(), player.getDisplayName().getString());
} }
@Inject(method = "canTarget(Lnet/minecraft/entity/LivingEntity;)Z", at = @At("HEAD"), cancellable = true) @Inject(method = "canTarget(Lnet/minecraft/entity/LivingEntity;)Z", at = @At("HEAD"), cancellable = true)
......
...@@ -54,7 +54,7 @@ public class MixinMobEntity { ...@@ -54,7 +54,7 @@ public class MixinMobEntity {
// Get chat data for entity // Get chat data for entity
ChatDataManager chatDataManager = ChatDataManager.getServerInstance(); ChatDataManager chatDataManager = ChatDataManager.getServerInstance();
EntityChatData entityData = chatDataManager.getOrCreateChatData(thisEntity.getUuidAsString(), player.getUuidAsString()); EntityChatData entityData = chatDataManager.getOrCreateChatData(thisEntity.getUuidAsString(), player.getDisplayName().getString());
PlayerData playerData = entityData.getPlayerData(player.getDisplayName().getString()); PlayerData playerData = entityData.getPlayerData(player.getDisplayName().getString());
// Check if the player successfully interacts with an item // Check if the player successfully interacts with an item
......
...@@ -93,7 +93,7 @@ public class ServerPackets { ...@@ -93,7 +93,7 @@ public class ServerPackets {
server.execute(() -> { server.execute(() -> {
MobEntity entity = (MobEntity)ServerEntityFinder.getEntityByUUID(player.getServerWorld(), entityId); MobEntity entity = (MobEntity)ServerEntityFinder.getEntityByUUID(player.getServerWorld(), entityId);
if (entity != null) { if (entity != null) {
EntityChatData chatData = ChatDataManager.getServerInstance().getOrCreateChatData(entity.getUuidAsString(), player.getUuidAsString()); EntityChatData chatData = ChatDataManager.getServerInstance().getOrCreateChatData(entity.getUuidAsString(), player.getDisplayName().getString());
if (chatData.characterSheet.isEmpty()) { if (chatData.characterSheet.isEmpty()) {
generate_character(userLanguage, chatData, player, entity); generate_character(userLanguage, chatData, player, entity);
} }
...@@ -114,7 +114,7 @@ public class ServerPackets { ...@@ -114,7 +114,7 @@ public class ServerPackets {
TalkPlayerGoal talkGoal = new TalkPlayerGoal(player, entity, 3.5F); TalkPlayerGoal talkGoal = new TalkPlayerGoal(player, entity, 3.5F);
EntityBehaviorManager.addGoal(entity, talkGoal, GoalPriority.TALK_PLAYER); EntityBehaviorManager.addGoal(entity, talkGoal, GoalPriority.TALK_PLAYER);
EntityChatData chatData = ChatDataManager.getServerInstance().getOrCreateChatData(entity.getUuidAsString(), player.getUuidAsString()); EntityChatData chatData = ChatDataManager.getServerInstance().getOrCreateChatData(entity.getUuidAsString(), player.getDisplayName().getString());
LOGGER.debug("Update read lines to " + lineNumber + " for: " + entity.getType().toString()); LOGGER.debug("Update read lines to " + lineNumber + " for: " + entity.getType().toString());
chatData.setLineNumber(lineNumber); chatData.setLineNumber(lineNumber);
} }
...@@ -134,7 +134,7 @@ public class ServerPackets { ...@@ -134,7 +134,7 @@ public class ServerPackets {
TalkPlayerGoal talkGoal = new TalkPlayerGoal(player, entity, 3.5F); TalkPlayerGoal talkGoal = new TalkPlayerGoal(player, entity, 3.5F);
EntityBehaviorManager.addGoal(entity, talkGoal, GoalPriority.TALK_PLAYER); EntityBehaviorManager.addGoal(entity, talkGoal, GoalPriority.TALK_PLAYER);
EntityChatData chatData = ChatDataManager.getServerInstance().getOrCreateChatData(entity.getUuidAsString(), player.getUuidAsString()); EntityChatData chatData = ChatDataManager.getServerInstance().getOrCreateChatData(entity.getUuidAsString(), player.getDisplayName().getString());
LOGGER.debug("Hiding chat bubble for: " + entity.getType().toString()); LOGGER.debug("Hiding chat bubble for: " + entity.getType().toString());
chatData.setStatus(ChatDataManager.ChatStatus.valueOf(status_name)); chatData.setStatus(ChatDataManager.ChatStatus.valueOf(status_name));
} }
...@@ -178,7 +178,7 @@ public class ServerPackets { ...@@ -178,7 +178,7 @@ public class ServerPackets {
server.execute(() -> { server.execute(() -> {
MobEntity entity = (MobEntity)ServerEntityFinder.getEntityByUUID(player.getServerWorld(), entityId); MobEntity entity = (MobEntity)ServerEntityFinder.getEntityByUUID(player.getServerWorld(), entityId);
if (entity != null) { if (entity != null) {
EntityChatData chatData = ChatDataManager.getServerInstance().getOrCreateChatData(entity.getUuidAsString(), player.getUuidAsString()); EntityChatData chatData = ChatDataManager.getServerInstance().getOrCreateChatData(entity.getUuidAsString(), player.getDisplayName().getString());
if (chatData.characterSheet.isEmpty()) { if (chatData.characterSheet.isEmpty()) {
generate_character(userLanguage, chatData, player, entity); generate_character(userLanguage, chatData, player, entity);
} else { } else {
...@@ -249,8 +249,8 @@ public class ServerPackets { ...@@ -249,8 +249,8 @@ public class ServerPackets {
ServerEntityEvents.ENTITY_UNLOAD.register((entity, world) -> { ServerEntityEvents.ENTITY_UNLOAD.register((entity, world) -> {
String entityUUID = entity.getUuidAsString(); String entityUUID = entity.getUuidAsString();
if (entity.getRemovalReason() == Entity.RemovalReason.KILLED && ChatDataManager.getServerInstance().entityChatDataMap.containsKey(entityUUID)) { if (entity.getRemovalReason() == Entity.RemovalReason.KILLED && ChatDataManager.getServerInstance().entityChatDataMap.containsKey(entityUUID)) {
LOGGER.info("Entity killed (" + entityUUID + "), removing chat data."); LOGGER.info("Entity killed (" + entityUUID + "), updating death time stamp.");
ChatDataManager.getServerInstance().entityChatDataMap.remove(entityUUID); ChatDataManager.getServerInstance().entityChatDataMap.get(entityUUID).death = System.currentTimeMillis();
} }
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment