mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-08 17:37:42 +01:00
Fix unsigned message
Signed-off-by: TheMode <themode@outlook.fr>
This commit is contained in:
parent
f09fdd862b
commit
7ba55fdfef
@ -32,15 +32,13 @@ public class ChatMessageListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void chatMessageListener(ClientChatMessagePacket packet, Player player) {
|
public static void chatMessageListener(ClientChatMessagePacket packet, Player player) {
|
||||||
System.out.println("packet "+packet);
|
|
||||||
final String message = "test";
|
|
||||||
if (!Messenger.canReceiveMessage(player)) {
|
if (!Messenger.canReceiveMessage(player)) {
|
||||||
Messenger.sendRejectionMessage(player);
|
Messenger.sendRejectionMessage(player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Collection<Player> players = CONNECTION_MANAGER.getOnlinePlayers();
|
final Collection<Player> players = CONNECTION_MANAGER.getOnlinePlayers();
|
||||||
PlayerChatEvent playerChatEvent = new PlayerChatEvent(player, players, () -> buildDefaultChatMessage(player, message), message);
|
PlayerChatEvent playerChatEvent = new PlayerChatEvent(player, players, () -> buildDefaultChatMessage(player, packet.message()), packet.message());
|
||||||
|
|
||||||
// Call the event
|
// Call the event
|
||||||
EventDispatcher.callCancellable(playerChatEvent, () -> {
|
EventDispatcher.callCancellable(playerChatEvent, () -> {
|
||||||
|
@ -1,42 +1,32 @@
|
|||||||
package net.minestom.server.network.packet.client.play;
|
package net.minestom.server.network.packet.client.play;
|
||||||
|
|
||||||
import net.kyori.adventure.text.Component;
|
|
||||||
import net.minestom.server.crypto.ChatBound;
|
|
||||||
import net.minestom.server.crypto.FilterMask;
|
|
||||||
import net.minestom.server.crypto.MessageSignature;
|
|
||||||
import net.minestom.server.crypto.SignedMessageBody;
|
|
||||||
import net.minestom.server.network.NetworkBuffer;
|
import net.minestom.server.network.NetworkBuffer;
|
||||||
import net.minestom.server.network.packet.client.ClientPacket;
|
import net.minestom.server.network.packet.client.ClientPacket;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.Arrays;
|
||||||
|
import java.util.BitSet;
|
||||||
|
|
||||||
import static net.minestom.server.network.NetworkBuffer.COMPONENT;
|
import static net.minestom.server.network.NetworkBuffer.*;
|
||||||
import static net.minestom.server.network.NetworkBuffer.VAR_INT;
|
|
||||||
|
|
||||||
public record ClientChatMessagePacket(@NotNull UUID sender, int index,
|
public record ClientChatMessagePacket(String message, long timestamp,
|
||||||
@Nullable MessageSignature signature,
|
long salt, byte @Nullable [] signature,
|
||||||
SignedMessageBody.@NotNull Packed body,
|
int ackOffset, BitSet ackList) implements ClientPacket {
|
||||||
@Nullable Component unsignedContent, FilterMask filterMask,
|
|
||||||
@NotNull ChatBound chatBound) implements ClientPacket {
|
|
||||||
|
|
||||||
public ClientChatMessagePacket(@NotNull NetworkBuffer reader) {
|
public ClientChatMessagePacket(@NotNull NetworkBuffer reader) {
|
||||||
this(reader.read(NetworkBuffer.UUID), reader.read(VAR_INT),
|
this(reader.read(STRING), reader.read(LONG),
|
||||||
reader.readOptional(MessageSignature::new),
|
reader.read(LONG), reader.readOptional(r -> r.readBytes(256)),
|
||||||
new SignedMessageBody.Packed(reader),
|
reader.read(VAR_INT), BitSet.valueOf(reader.readBytes(3)));
|
||||||
reader.readOptional(COMPONENT), new FilterMask(reader),
|
|
||||||
new ChatBound(reader));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(@NotNull NetworkBuffer writer) {
|
public void write(@NotNull NetworkBuffer writer) {
|
||||||
writer.write(NetworkBuffer.UUID, sender);
|
writer.write(STRING, message);
|
||||||
writer.write(VAR_INT, index);
|
writer.write(LONG, timestamp);
|
||||||
writer.writeOptional(signature);
|
writer.write(LONG, salt);
|
||||||
writer.write(body);
|
writer.writeOptional(BYTE_ARRAY, signature);
|
||||||
writer.writeOptional(COMPONENT, unsignedContent);
|
writer.write(VAR_INT, ackOffset);
|
||||||
writer.write(filterMask);
|
writer.write(RAW_BYTES, Arrays.copyOf(ackList.toByteArray(), 3));
|
||||||
writer.write(chatBound);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user