oh no my extensive debugging setup

This commit is contained in:
Camotoy 2022-02-10 20:15:46 -05:00
parent 746cd94dd1
commit 0ca77233ed
No known key found for this signature in database
GPG key ID: 7EEFB66FE798081F

View file

@ -30,45 +30,11 @@ import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.translator.protocol.PacketTranslator; import org.geysermc.geyser.translator.protocol.PacketTranslator;
import org.geysermc.geyser.translator.protocol.Translator; import org.geysermc.geyser.translator.protocol.Translator;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
@Translator(packet = ClientboundUpdateTagsPacket.class) @Translator(packet = ClientboundUpdateTagsPacket.class)
public class JavaUpdateTagsTranslator extends PacketTranslator<ClientboundUpdateTagsPacket> { public class JavaUpdateTagsTranslator extends PacketTranslator<ClientboundUpdateTagsPacket> {
private final Map<String, Map<String, int[]>> previous = new HashMap<>();
@Override @Override
public void translate(GeyserSession session, ClientboundUpdateTagsPacket packet) { public void translate(GeyserSession session, ClientboundUpdateTagsPacket packet) {
for (Map.Entry<String, Map<String, int[]>> entry : packet.getTags().entrySet().stream().sorted(Map.Entry.comparingByKey()).toList()) {
StringBuilder builder = new StringBuilder();
builder.append(entry.getKey()).append("={");
for (Map.Entry<String, int[]> tag : entry.getValue().entrySet().stream().sorted(Map.Entry.comparingByKey()).toList()) {
builder.append(tag.getKey()).append('=').append(Arrays.toString(tag.getValue())).append(", ");
}
System.out.println(builder.append("}").toString());
}
if (previous.isEmpty()) {
previous.putAll(packet.getTags());
} else {
for (Map.Entry<String, Map<String, int[]>> entry : packet.getTags().entrySet()) {
Map<String, int[]> oldTags = previous.get(entry.getKey());
for (Map.Entry<String, int[]> newTag : entry.getValue().entrySet()) {
int[] oldValue = oldTags.get(newTag.getKey());
if (oldValue == null) {
System.out.println("Tag " + newTag.getKey() + " not found!!");
continue;
}
if (!Arrays.equals(Arrays.stream(oldValue).sorted().toArray(), Arrays.stream(newTag.getValue()).sorted().toArray())) {
System.out.println(entry.getKey() + ": " + newTag.getKey() + " has different values! " + Arrays.toString(Arrays.stream(oldValue).sorted().toArray()) + " " + Arrays.toString(Arrays.stream(newTag.getValue()).sorted().toArray()));
}
}
}
}
session.getTagCache().loadPacket(session, packet); session.getTagCache().loadPacket(session, packet);
} }
} }