Commit 881437f9 by Jonathan Thomas

Adding timestamps to ChatMessage (long based unix timestamp format), also sets…

Adding timestamps to ChatMessage (long based unix timestamp format), also sets them during migration
parent 6774a95a
Pipeline #12881 passed with stages
in 2 minutes 2 seconds
......@@ -14,7 +14,7 @@ All notable changes to **CreatureChat** are documented in this file. The format
- New animated attack particles (with random # of particles)
### Changed
- Entity chat data now separates messages and friendship by player
- Entity chat data now separates messages and friendship by player and includes timestamps
- 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
......
......@@ -2,12 +2,8 @@ package com.owlmaddie.chat;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.owlmaddie.commands.ConfigurationHandler;
import com.owlmaddie.items.RarityItemCollector;
import com.owlmaddie.json.QuestJson;
import com.owlmaddie.network.ServerPackets;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.Rarity;
import net.minecraft.util.WorldSavePath;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -15,7 +11,8 @@ import org.slf4j.LoggerFactory;
import java.io.*;
import java.lang.reflect.Type;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.HashMap;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
/**
......@@ -32,7 +29,6 @@ public class ChatDataManager {
public static int MAX_CHAR_IN_USER_MESSAGE = 512;
public static int TICKS_TO_DISPLAY_USER_MESSAGE = 70;
public static int MAX_AUTOGENERATE_RESPONSES = 3;
public QuestJson quest = null;
private static final Gson GSON = new Gson();
public enum ChatStatus {
......
......@@ -6,9 +6,11 @@ package com.owlmaddie.chat;
public class ChatMessage {
public String message;
public ChatDataManager.ChatSender sender;
public Long timestamp;
public ChatMessage(String message, ChatDataManager.ChatSender sender) {
this.message = message;
this.sender = sender;
this.timestamp = System.currentTimeMillis();
}
}
\ No newline at end of file
......@@ -95,8 +95,10 @@ public class EntityChatData {
// Ensure the blank player data entry exists
PlayerData blankPlayerData = this.players.computeIfAbsent("", k -> new PlayerData());
// Migrate the old data to the blank player
// Migrate the old data to the blank player and assign timestamps if missing
if (this.legacyMessages != null) {
this.legacyMessages.forEach(message -> message.timestamp =
message.timestamp != null ? message.timestamp : System.currentTimeMillis());
blankPlayerData.messages.addAll(this.legacyMessages);
}
blankPlayerData.friendship = this.legacyFriendship;
......
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