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
### Changed
- 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
- 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
......
......@@ -114,7 +114,7 @@ public class ClientPackets {
MobEntity entity = ClientEntityFinder.getEntityByUUID(client.world, entityId);
if (entity != null) {
ChatDataManager chatDataManager = ChatDataManager.getClientInstance();
EntityChatData chatData = chatDataManager.getOrCreateChatData(entity.getUuidAsString(), playerId.toString());
EntityChatData chatData = chatDataManager.getOrCreateChatData(entity.getUuidAsString(), playerName);
if (!message.isEmpty()) {
chatData.currentMessage = message;
}
......
......@@ -479,7 +479,7 @@ public class BubbleRenderer {
EntityChatData chatData = null;
PlayerData playerData = null;
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());
} else if (entity instanceof PlayerEntity) {
chatData = PlayerMessageManager.getMessage(entity.getUuid());
......
......@@ -120,7 +120,7 @@ public class ClickHandler {
MobEntity closestEntity = ClientEntityFinder.getEntityByUUID(client.world, closestEntityUUID);
if (closestEntity != null) {
// 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)
String hitRegion = determineHitRegion(closestHitResult.get(), closestBubbleData.position, camera, closestBubbleData.height);
......
......@@ -73,8 +73,8 @@ public class ChatDataManager {
}
// Retrieve chat data for a specific entity, or create it if it doesn't exist
public EntityChatData getOrCreateChatData(String entityId, String playerId) {
return entityChatDataMap.computeIfAbsent(entityId, k -> new EntityChatData(entityId, playerId));
public EntityChatData getOrCreateChatData(String entityId, String playerName) {
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)
......
......@@ -51,6 +51,8 @@ public class EntityChatData {
public ChatDataManager.ChatSender sender;
public int auto_generated;
public List<ChatMessage> previousMessages;
public Long born;
public Long death;
@SerializedName("playerId")
@Expose(serialize = false)
......@@ -63,11 +65,11 @@ public class EntityChatData {
// The map to store data for each player interacting with this entity
public Map<String, PlayerData> players;
public EntityChatData(String entityId, String playerId) {
public EntityChatData(String entityId, String playerName) {
this.entityId = entityId;
this.players = new HashMap<>();
if (!playerId.isEmpty()) {
this.players.put(playerId, new PlayerData());
if (!playerName.isEmpty()) {
this.players.put(playerName, new PlayerData());
}
this.currentMessage = "";
this.currentLineNumber = 0;
......@@ -76,6 +78,7 @@ public class EntityChatData {
this.sender = ChatDataManager.ChatSender.USER;
this.auto_generated = 0;
this.previousMessages = new ArrayList<>();
this.born = System.currentTimeMillis();;
// Old, unused migrated properties
this.legacyPlayerId = null;
......@@ -106,6 +109,9 @@ public class EntityChatData {
}
}
blankPlayerData.friendship = this.legacyFriendship;
if (this.born == null) {
this.born = System.currentTimeMillis();;
}
// Clean up old player data
this.legacyPlayerId = null;
......
......@@ -71,7 +71,7 @@ public class LeadPlayerGoal extends PlayerBaseGoal {
String arrivedMessage = "<You have arrived at your destination>";
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) {
ServerPackets.generate_chat("N/A", chatData, (ServerPlayerEntity) this.targetEntity, this.entity, arrivedMessage, true);
}
......
......@@ -25,7 +25,7 @@ public class MixinLivingEntity {
private EntityChatData getChatData(LivingEntity entity, PlayerEntity player) {
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)
......
......@@ -54,7 +54,7 @@ public class MixinMobEntity {
// Get chat data for entity
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());
// Check if the player successfully interacts with an item
......
......@@ -93,7 +93,7 @@ public class ServerPackets {
server.execute(() -> {
MobEntity entity = (MobEntity)ServerEntityFinder.getEntityByUUID(player.getServerWorld(), entityId);
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()) {
generate_character(userLanguage, chatData, player, entity);
}
......@@ -114,7 +114,7 @@ public class ServerPackets {
TalkPlayerGoal talkGoal = new TalkPlayerGoal(player, entity, 3.5F);
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());
chatData.setLineNumber(lineNumber);
}
......@@ -134,7 +134,7 @@ public class ServerPackets {
TalkPlayerGoal talkGoal = new TalkPlayerGoal(player, entity, 3.5F);
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());
chatData.setStatus(ChatDataManager.ChatStatus.valueOf(status_name));
}
......@@ -178,7 +178,7 @@ public class ServerPackets {
server.execute(() -> {
MobEntity entity = (MobEntity)ServerEntityFinder.getEntityByUUID(player.getServerWorld(), entityId);
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()) {
generate_character(userLanguage, chatData, player, entity);
} else {
......@@ -249,8 +249,8 @@ public class ServerPackets {
ServerEntityEvents.ENTITY_UNLOAD.register((entity, world) -> {
String entityUUID = entity.getUuidAsString();
if (entity.getRemovalReason() == Entity.RemovalReason.KILLED && ChatDataManager.getServerInstance().entityChatDataMap.containsKey(entityUUID)) {
LOGGER.info("Entity killed (" + entityUUID + "), removing chat data.");
ChatDataManager.getServerInstance().entityChatDataMap.remove(entityUUID);
LOGGER.info("Entity killed (" + entityUUID + "), updating death time stamp.");
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