Fixed SerializableData#clone

This commit is contained in:
Felix Cravic 2020-07-01 00:40:39 +02:00
parent c5b83f1054
commit 151dedca99
4 changed files with 10 additions and 4 deletions

View File

@ -1,5 +1,6 @@
package net.minestom.server.chat;
import net.kyori.text.Component;
import net.kyori.text.serializer.gson.GsonComponentSerializer;
import net.kyori.text.serializer.legacy.LegacyComponentSerializer;

View File

@ -28,9 +28,10 @@ public class SerializableData extends Data {
@Override
public Data clone() {
SerializableData cloned = (SerializableData) super.clone();
cloned.dataType = new ConcurrentHashMap<>(dataType);
return super.clone();
SerializableData data = new SerializableData();
data.data = new ConcurrentHashMap<>(this.data);
data.dataType = new ConcurrentHashMap<>(dataType);
return data;
}
public byte[] getSerializedData() throws IOException {

View File

@ -17,13 +17,16 @@ import java.util.UUID;
public class LoginStartPacket implements ClientPreplayPacket {
private static final String ALREADY_CONNECTED_JSON =
ColoredText.of(ChatColor.RED, "You are already on this server").toString();
public String username;
@Override
public void process(PlayerConnection connection, ConnectionManager connectionManager) {
if (MojangAuth.isUsingMojangAuth()) {
if (connectionManager.getPlayer(username) != null) {
connection.sendPacket(new LoginDisconnect(ColoredText.of(ChatColor.RED, "You are already on this server").toString()));
connection.sendPacket(new LoginDisconnect(ALREADY_CONNECTED_JSON));
connection.disconnect();
return;
}

View File

@ -15,6 +15,7 @@ public class EntityEquipmentPacket implements ServerPacket {
@Override
public void write(PacketWriter writer) {
writer.writeVarInt(entityId);
// TODO multiple equipments
writer.writeByte((byte) slot.ordinal());
writer.writeItemStack(itemStack);
}