Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 104 additions & 0 deletions src/com/comphenix/packetwrapper/WrapperPlayServerChat.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
/**
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;

import java.util.Arrays;

import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.wrappers.EnumWrappers;
import com.comphenix.protocol.wrappers.EnumWrappers.ChatType;
import com.comphenix.protocol.wrappers.WrappedChatComponent;

public class WrapperPlayServerChat extends AbstractPacket {
public static final PacketType TYPE = PacketType.Play.Server.CHAT;

public WrapperPlayServerChat() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
}

public WrapperPlayServerChat(PacketContainer packet) {
super(packet, TYPE);
}

/**
* Retrieve the chat message.
* <p>
* Limited to 32767 bytes
*
* @return The current message
*/
public WrappedChatComponent getMessage() {
return handle.getChatComponents().read(0);
}

/**
* Set the message.
*
* @param value - new value.
*/
public void setMessage(WrappedChatComponent value) {
handle.getChatComponents().write(0, value);
}

public ChatType getChatType() {
return handle.getChatTypes().read(0);
}

public void setChatType(ChatType type) {
handle.getChatTypes().write(0, type);
}

/**
* Retrieve Position.
* <p>
* Notes: 0 - Chat (chat box) ,1 - System Message (chat box), 2 - Above
* action bar
*
* @return The current Position
* @deprecated Magic values replaced by enum
*/
@Deprecated
public byte getPosition() {
Byte position = handle.getBytes().readSafely(0);
if (position != null) {
return position;
} else {
return getChatType().getId();
}
}

/**
* Set Position.
*
* @param value - new value.
* @deprecated Magic values replaced by enum
*/
@Deprecated
public void setPosition(byte value) {
handle.getBytes().writeSafely(0, value);

if (EnumWrappers.getChatTypeClass() != null)
{
Arrays.stream(ChatType.values()).filter(t -> t.getId() == value).findAny()
.ifPresent(t -> handle.getChatTypes().writeSafely(0, t));
}
}
}
18 changes: 3 additions & 15 deletions src/me/jumper251/replay/filesystem/ConfigManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,12 @@ public class ConfigManager {

public static boolean RECORD_BLOCKS, REAL_CHANGES;
public static boolean RECORD_ITEMS, RECORD_ENTITIES;
public static boolean RECORD_CHAT;
public static boolean RECORD_CHAT, RECORD_PLUGIN_MESSAGES;
public static boolean SAVE_STOP, USE_OFFLINE_SKINS, HIDE_PLAYERS, UPDATE_NOTIFY, USE_DATABASE, ADD_PLAYERS;
public static boolean WORLD_RESET;

public static ReplayQuality QUALITY = ReplayQuality.HIGH;

public static String DEATH_MESSAGE, LEAVE_MESSAGE, CHAT_FORMAT, JOIN_MESSAGE;

public static void loadConfigs() {
if(!sqlFile.exists()){
sqlCfg.set("host", "localhost");
Expand All @@ -60,10 +58,6 @@ public static void loadConfigs() {
cfg.set("general.hide_players", false);
cfg.set("general.add_new_players", false);
cfg.set("general.update_notifications", true);

cfg.set("general.death_message", "&6{name} &7died.");
cfg.set("general.quit_message", "&6{name} &7left the game.");
cfg.set("general.join_message", "&6{name} &7joined the game.");

cfg.set("replaying.world.reset_changes", false);

Expand All @@ -72,7 +66,7 @@ public static void loadConfigs() {
cfg.set("recording.entities.enabled", false);
cfg.set("recording.entities.items.enabled", true);
cfg.set("recording.chat.enabled", false);
cfg.set("recording.chat.format", "&r<{name}> {message}");
cfg.set("recording.chat.plugin_messages", false);


try {
Expand All @@ -98,19 +92,13 @@ public static void loadData(boolean initial) {
ADD_PLAYERS = cfg.getBoolean("general.add_new_players");
UPDATE_NOTIFY = cfg.getBoolean("general.update_notifications");
if (initial ) USE_DATABASE = cfg.getBoolean("general.use_mysql");

DEATH_MESSAGE = cfg.getString("general.death_message");
LEAVE_MESSAGE = cfg.getString("general.quit_message");
JOIN_MESSAGE = cfg.getString("general.join_message");

WORLD_RESET = cfg.getBoolean("replaying.world.reset_changes", false);

CHAT_FORMAT = cfg.getString("recording.chat.format");
RECORD_BLOCKS = cfg.getBoolean("recording.blocks.enabled");
REAL_CHANGES = cfg.getBoolean("recording.blocks.real_changes");
RECORD_ITEMS = cfg.getBoolean("recording.entities.items.enabled");
RECORD_ENTITIES = cfg.getBoolean("recording.entities.enabled");
RECORD_CHAT = cfg.getBoolean("recording.chat.enabled");
RECORD_PLUGIN_MESSAGES = cfg.getBoolean("recording.chat.plugin_messages");

if (USE_DATABASE) {

Expand Down
10 changes: 9 additions & 1 deletion src/me/jumper251/replay/replaysystem/data/ReplayData.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.util.List;

import me.jumper251.replay.filesystem.ConfigManager;
import me.jumper251.replay.replaysystem.data.types.ChatData;
import me.jumper251.replay.replaysystem.recording.PlayerWatcher;
import me.jumper251.replay.replaysystem.recording.optimization.ReplayQuality;

Expand All @@ -18,6 +19,8 @@ public class ReplayData implements Serializable{


private HashMap<Integer, List<ActionData>> actions;

private HashMap<Integer, List<ChatData>> messages;

private HashMap<String, PlayerWatcher> watchers;

Expand All @@ -29,6 +32,7 @@ public class ReplayData implements Serializable{

public ReplayData() {
this.actions = new HashMap<Integer, List<ActionData>>();
this.messages = new HashMap<Integer, List<ChatData>>();
this.watchers = new HashMap<String, PlayerWatcher>();

this.quality = ConfigManager.QUALITY;
Expand Down Expand Up @@ -57,7 +61,11 @@ public ReplayQuality getQuality() {
public HashMap<Integer, List<ActionData>> getActions() {
return actions;
}


public HashMap<Integer, List<ChatData>> getMessages() {
return messages;
}

public HashMap<String, PlayerWatcher> getWatchers() {
return watchers;
}
Expand Down
25 changes: 25 additions & 0 deletions src/me/jumper251/replay/replaysystem/data/types/ChatData.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package me.jumper251.replay.replaysystem.data.types;

import java.util.HashSet;
import java.util.Set;

public class ChatData extends PacketData {


Expand All @@ -8,12 +11,34 @@ public class ChatData extends PacketData {
*/
private static final long serialVersionUID = 6849586468365004854L;

private Set<String> recipients;
private String message;

/**
* Constructs a ChatData with provided message and an empty recipient.
*
* @param message the message
*/
public ChatData(String message) {
this.recipients = new HashSet<>();
this.message = message;
}

/**
* Constructs a ChatData with provided message and recipient.
*
* @param recipients the recipient
* @param message the message
*/
public ChatData(Set<String> recipients, String message) {
this.recipients = recipients;
this.message = message;
}

public Set<String> getRecipients() {
return recipients;
}

public String getMessage() {
return message;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
import net.md_5.bungee.chat.ComponentSerializer;
import net.md_5.bungee.api.chat.TextComponent;

import com.comphenix.packetwrapper.WrapperPlayClientBlockDig;
import com.comphenix.packetwrapper.WrapperPlayClientEntityAction;
Expand All @@ -32,6 +34,7 @@
import com.comphenix.packetwrapper.WrapperPlayServerRelEntityMoveLook;
import com.comphenix.packetwrapper.WrapperPlayServerSpawnEntity;
import com.comphenix.packetwrapper.WrapperPlayServerSpawnEntityLiving;
import com.comphenix.packetwrapper.WrapperPlayServerChat;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.events.ListenerPriority;
Expand Down Expand Up @@ -102,7 +105,7 @@ public void register() {
this.packetAdapter = new PacketAdapter(ReplaySystem.getInstance(), ListenerPriority.HIGHEST,
PacketType.Play.Client.POSITION, PacketType.Play.Client.POSITION_LOOK, PacketType.Play.Client.LOOK, PacketType.Play.Client.ENTITY_ACTION, PacketType.Play.Client.ARM_ANIMATION,
PacketType.Play.Client.BLOCK_DIG, PacketType.Play.Server.SPAWN_ENTITY, PacketType.Play.Server.ENTITY_DESTROY, PacketType.Play.Server.ENTITY_VELOCITY, PacketType.Play.Server.SPAWN_ENTITY_LIVING,
PacketType.Play.Server.REL_ENTITY_MOVE, PacketType.Play.Server.REL_ENTITY_MOVE_LOOK, PacketType.Play.Server.ENTITY_LOOK, PacketType.Play.Server.POSITION, PacketType.Play.Server.ENTITY_TELEPORT) {
PacketType.Play.Server.REL_ENTITY_MOVE, PacketType.Play.Server.REL_ENTITY_MOVE_LOOK, PacketType.Play.Server.ENTITY_LOOK, PacketType.Play.Server.POSITION, PacketType.Play.Server.ENTITY_TELEPORT, PacketType.Play.Server.CHAT) {
@Override
public void onPacketReceiving(PacketEvent event) {

Expand Down Expand Up @@ -306,6 +309,16 @@ public void onPacketSending(PacketEvent event) {
addData(p.getName(), new EntityMovingData(packet.getEntityID(), loc.getX(), loc.getY(), loc.getZ(), packet.getPitch(), packet.getYaw()));
}
}
if(event.getPacketType() == PacketType.Play.Server.CHAT) {
if(ConfigManager.RECORD_CHAT && ConfigManager.RECORD_PLUGIN_MESSAGES) {

WrapperPlayServerChat packet = new WrapperPlayServerChat(event.getPacket());

String message = new TextComponent(ComponentSerializer.parse(packet.getMessage().getJson())).toLegacyText();
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did some tests on Spigot 1.8.8 and there is an error message with plugin_messages enabled while trying to record death messages. I think the ComponentSerializer cannot parse the message.

[17:53:59 ERROR]: [AdvancedReplay] Unhandled exception occured in onPacketSending(PacketEvent) for AdvancedReplay java.lang.IllegalArgumentException: No enum constant net.md_5.bungee.api.chat.HoverEvent.Action.SHOW_ENTITY at java.base/java.lang.Enum.valueOf(Unknown Source) ~[?:?] at net.md_5.bungee.api.chat.HoverEvent$Action.valueOf(HoverEvent.java:16) ~[spigot_server-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24] at net.md_5.bungee.chat.BaseComponentSerializer.deserialize(BaseComponentSerializer.java:71) ~[spigot_server-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24] at net.md_5.bungee.chat.TextComponentSerializer.deserialize(TextComponentSerializer.java:25) ~[spigot_server-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24] at net.md_5.bungee.chat.TextComponentSerializer.deserialize(TextComponentSerializer.java:17) ~[spigot_server-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24] at com.google.gson.TreeTypeAdapter.read(TreeTypeAdapter.java:58) ~[spigot_server-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24] at com.google.gson.Gson.fromJson(Gson.java:803) ~[spigot_server-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24] at com.google.gson.Gson.fromJson(Gson.java:868) ~[spigot_server-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24] at com.google.gson.Gson$1.deserialize(Gson.java:126) ~[spigot_server-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24] at net.md_5.bungee.chat.ComponentSerializer.deserialize(ComponentSerializer.java:62) ~[spigot_server-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24] at net.md_5.bungee.chat.ComponentSerializer.deserialize(ComponentSerializer.java:17) ~[spigot_server-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24] at com.google.gson.TreeTypeAdapter.read(TreeTypeAdapter.java:58) ~[spigot_server-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24] at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.read(TypeAdapterRuntimeTypeWrapper.java:40) ~[spigot_server-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24] at com.google.gson.internal.bind.ArrayTypeAdapter.read(ArrayTypeAdapter.java:72) ~[spigot_server-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24] at com.google.gson.Gson.fromJson(Gson.java:803) ~[spigot_server-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24] at com.google.gson.Gson.fromJson(Gson.java:868) ~[spigot_server-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24] at com.google.gson.Gson$1.deserialize(Gson.java:126) ~[spigot_server-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24] at net.md_5.bungee.chat.TranslatableComponentSerializer.deserialize(TranslatableComponentSerializer.java:28) ~[spigot_server-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24] at net.md_5.bungee.chat.TranslatableComponentSerializer.deserialize(TranslatableComponentSerializer.java:16) ~[spigot_server-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24] at com.google.gson.TreeTypeAdapter.read(TreeTypeAdapter.java:58) ~[spigot_server-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24] at com.google.gson.Gson.fromJson(Gson.java:803) ~[spigot_server-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24] at com.google.gson.Gson.fromJson(Gson.java:868) ~[spigot_server-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24] at com.google.gson.Gson$1.deserialize(Gson.java:126) ~[spigot_server-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24] at net.md_5.bungee.chat.ComponentSerializer.deserialize(ComponentSerializer.java:60) ~[spigot_server-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24] at net.md_5.bungee.chat.ComponentSerializer.deserialize(ComponentSerializer.java:17) ~[spigot_server-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24] at com.google.gson.TreeTypeAdapter.read(TreeTypeAdapter.java:58) ~[spigot_server-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24] at com.google.gson.Gson.fromJson(Gson.java:803) ~[spigot_server-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24] at com.google.gson.Gson.fromJson(Gson.java:768) ~[spigot_server-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24] at com.google.gson.Gson.fromJson(Gson.java:717) ~[spigot_server-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24] at com.google.gson.Gson.fromJson(Gson.java:689) ~[spigot_server-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24] at net.md_5.bungee.chat.ComponentSerializer.parse(ComponentSerializer.java:34) ~[spigot_server-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24] at me.jumper251.replay.replaysystem.recording.PacketRecorder$1.onPacketSending(PacketRecorder.java:317) ~[Replay.jar:?] at com.comphenix.protocol.injector.SortedPacketListenerList.invokeSendingListener(SortedPacketListenerList.java:195) [ProtocolLib-S4.jar:4.5.0] at com.comphenix.protocol.injector.SortedPacketListenerList.invokePacketSending(SortedPacketListenerList.java:149) [ProtocolLib-S4.jar:4.5.0] at com.comphenix.protocol.injector.PacketFilterManager.handlePacket(PacketFilterManager.java:588) [ProtocolLib-S4.jar:4.5.0] at com.comphenix.protocol.injector.PacketFilterManager.invokePacketSending(PacketFilterManager.java:564) [ProtocolLib-S4.jar:4.5.0] at com.comphenix.protocol.injector.netty.ProtocolInjector.packetQueued(ProtocolInjector.java:338) [ProtocolLib-S4.jar:4.5.0] at com.comphenix.protocol.injector.netty.ProtocolInjector.onPacketSending(ProtocolInjector.java:298) [ProtocolLib-S4.jar:4.5.0] at com.comphenix.protocol.injector.netty.ChannelInjector.processSending(ChannelInjector.java:378) [ProtocolLib-S4.jar:4.5.0] at com.comphenix.protocol.injector.netty.ChannelInjector.access$800(ChannelInjector.java:64) [ProtocolLib-S4.jar:4.5.0] at com.comphenix.protocol.injector.netty.ChannelInjector$3.handleScheduled(ChannelInjector.java:343) [ProtocolLib-S4.jar:4.5.0] at com.comphenix.protocol.injector.netty.ChannelInjector$3.onMessageScheduled(ChannelInjector.java:313) [ProtocolLib-S4.jar:4.5.0] at com.comphenix.protocol.injector.netty.ChannelProxy$2.schedulingRunnable(ChannelProxy.java:127) [ProtocolLib-S4.jar:4.5.0] at com.comphenix.protocol.injector.netty.EventLoopProxy.execute(EventLoopProxy.java:95) [ProtocolLib-S4.jar:4.5.0] at net.minecraft.server.v1_8_R3.NetworkManager.a(NetworkManager.java:192) [spigot_server-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24] at net.minecraft.server.v1_8_R3.NetworkManager.handle(NetworkManager.java:141) [spigot_server-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24] at net.minecraft.server.v1_8_R3.PlayerConnection.sendPacket(PlayerConnection.java:907) [spigot_server-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24] at net.minecraft.server.v1_8_R3.PlayerList.sendAll(PlayerList.java:880) [spigot_server-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24] at net.minecraft.server.v1_8_R3.PlayerList.sendMessage(PlayerList.java:1192) [spigot_server-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24] at net.minecraft.server.v1_8_R3.PlayerList.sendMessage(PlayerList.java:1197) [spigot_server-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24] at net.minecraft.server.v1_8_R3.EntityPlayer.die(EntityPlayer.java:423) [spigot_server-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24] at net.minecraft.server.v1_8_R3.EntityLiving.damageEntity(EntityLiving.java:812) [spigot_server-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24] at net.minecraft.server.v1_8_R3.EntityHuman.damageEntity(EntityHuman.java:800) [spigot_server-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24] at net.minecraft.server.v1_8_R3.EntityPlayer.damageEntity(EntityPlayer.java:496) [spigot_server-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24] at net.minecraft.server.v1_8_R3.EntityLiving.e(EntityLiving.java:939) [spigot_server-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24] at net.minecraft.server.v1_8_R3.EntityHuman.e(EntityHuman.java:1440) [spigot_server-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24] at net.minecraft.server.v1_8_R3.Block.fallOn(Block.java:640) [spigot_server-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24] at net.minecraft.server.v1_8_R3.Entity.a(Entity.java:811) [spigot_server-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24] at net.minecraft.server.v1_8_R3.EntityLiving.a(EntityLiving.java:160) [spigot_server-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24] at net.minecraft.server.v1_8_R3.EntityPlayer.a(EntityPlayer.java:621) [spigot_server-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24] at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:456) [spigot_server-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24] at net.minecraft.server.v1_8_R3.PacketPlayInFlying.a(SourceFile:126) [spigot_server-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24] at net.minecraft.server.v1_8_R3.PacketPlayInFlying$PacketPlayInPosition.a(SourceFile:57) [spigot_server-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24] at net.minecraft.server.v1_8_R3.PlayerConnectionUtils$1.run(SourceFile:13) [spigot_server-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24] at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:?] at java.base/java.util.concurrent.FutureTask.run(Unknown Source) [?:?] at net.minecraft.server.v1_8_R3.SystemUtils.a(SourceFile:44) [spigot_server-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24] at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:715) [spigot_server-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24] at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:374) [spigot_server-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24] at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654) [spigot_server-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24] at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557) [spigot_server-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24] at java.base/java.lang.Thread.run(Unknown Source) [?:?] [17:53:59 ERROR]: Parameters: net.minecraft.server.v1_8_R3.PacketPlayOutChat@7909c818[ a=TranslatableComponent{key='death.fell.accident.generic', args=[TextComponent{text='Jumper251', siblings=[], style=Style{hasParent=true, color=null, bold=null, italic=null, underlined=null, obfuscated=null, clickEvent=ClickEvent{action=SUGGEST_COMMAND, value='/msg Jumper251 '}, hoverEvent=HoverEvent{action=SHOW_ENTITY, value='TextComponent{text='{name:"Jumper251",id:"28bc683e-40e9-47bc-a1fb-e067b77d8262"}', siblings=[], style=Style{hasParent=false, color=null, bold=null, italic=null, underlined=null, obfuscated=null, clickEvent=null, hoverEvent=null, insertion=null}}'}, insertion=Jumper251}}], siblings=[], style=Style{hasParent=false, color=null, bold=null, italic=null, underlined=null, obfuscated=null, clickEvent=null, hoverEvent=null, insertion=null}} components=<null> b=1 ]

recorder.recordChat(p.getName(), message);

}
}

}

Expand Down
15 changes: 14 additions & 1 deletion src/me/jumper251/replay/replaysystem/recording/Recorder.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;

import com.google.common.collect.Sets;
import me.jumper251.replay.replaysystem.data.types.*;
import org.bukkit.Bukkit;
import org.bukkit.Location;
Expand Down Expand Up @@ -90,7 +92,6 @@ public void run() {
if (packetData instanceof BlockChangeData && !ConfigManager.RECORD_BLOCKS) continue;
if (packetData instanceof EntityItemData && !ConfigManager.RECORD_ITEMS) continue;
if ((packetData instanceof EntityData || packetData instanceof EntityMovingData || packetData instanceof EntityAnimationData) && !ConfigManager.RECORD_ENTITIES) continue;
if (packetData instanceof ChatData && !ConfigManager.RECORD_CHAT) continue;


ActionData actionData = new ActionData(currentTick, ActionType.PACKET, name, packetData);
Expand Down Expand Up @@ -204,6 +205,18 @@ public void run() {
}
}

public void recordChat(String player, String message) {
if(!data.getMessages().containsKey(currentTick)) {
data.getMessages().put(currentTick, new ArrayList<>());
}
Optional<ChatData> chatData = data.getMessages().get(currentTick).stream().filter(c -> c.getMessage().equals(message)).findAny();
if(chatData.isPresent()) {
chatData.get().getRecipients().add(player);
} else {
data.getMessages().get(currentTick).add(new ChatData(Sets.newHashSet(player), message));
}
}

public List<String> getPlayers() {
return players;
}
Expand Down
Loading