From 22a1073e548bd9c0c23abb95f36087671b498116 Mon Sep 17 00:00:00 2001 From: Camotoy <20743703+DoctorMacc@users.noreply.github.com> Date: Sat, 23 May 2020 17:11:54 -0400 Subject: [PATCH] Debugging improvements (#585) * Debugging improvements - Added an ObjectArrayList of packets we don't anticipate ever translating. Currently only holds ServerUpdateLightPacket which we don't use and probably don't need. - Only print debugging logs from sounds if they failed to play. * Add space --- .../connector/network/translators/Registry.java | 11 ++++++++++- .../java/world/JavaPlayBuiltinSoundTranslator.java | 5 +---- .../java/world/JavaPlayerPlaySoundTranslator.java | 7 +------ 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/Registry.java b/connector/src/main/java/org/geysermc/connector/network/translators/Registry.java index 70201ba88..399ec1a6d 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/Registry.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/Registry.java @@ -28,6 +28,8 @@ package org.geysermc.connector.network.translators; import java.util.HashMap; import java.util.Map; +import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerUpdateLightPacket; +import it.unimi.dsi.fastutil.objects.ObjectArrayList; import org.geysermc.connector.GeyserConnector; import org.geysermc.connector.network.session.GeyserSession; @@ -40,6 +42,12 @@ public class Registry { public static final Registry JAVA = new Registry<>(); public static final Registry BEDROCK = new Registry<>(); + private static final ObjectArrayList> IGNORED_PACKETS = new ObjectArrayList<>(); + + static { + IGNORED_PACKETS.add(ServerUpdateLightPacket.class); + } + public static void registerJava(Class targetPacket, PacketTranslator translator) { JAVA.MAP.put(targetPacket, translator); } @@ -56,7 +64,8 @@ public class Registry { ((PacketTranslator

) MAP.get(clazz)).translate(packet, session); return true; } else { - GeyserConnector.getInstance().getLogger().debug("Could not find packet for " + (packet.toString().length() > 25 ? packet.getClass().getSimpleName() : packet)); + if (!IGNORED_PACKETS.contains(clazz)) + GeyserConnector.getInstance().getLogger().debug("Could not find packet for " + (packet.toString().length() > 25 ? packet.getClass().getSimpleName() : packet)); } } catch (Throwable ex) { GeyserConnector.getInstance().getLogger().error("Could not translate packet " + packet.getClass().getSimpleName(), ex); diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaPlayBuiltinSoundTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaPlayBuiltinSoundTranslator.java index e060e0956..0a5274db8 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaPlayBuiltinSoundTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaPlayBuiltinSoundTranslator.java @@ -45,10 +45,8 @@ public class JavaPlayBuiltinSoundTranslator extends PacketTranslator " - + soundMapping + (soundMapping == null ? "[not found]" : "") - + " - " + packet.toString()); if (soundMapping == null) { + session.getConnector().getLogger().debug("[Builtin] Sound mapping " + packetSound + " not found - " + packet.toString()); return; } @@ -93,6 +91,5 @@ public class JavaPlayBuiltinSoundTranslator extends PacketTranslator " + soundPacket.toString()); } } diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaPlayerPlaySoundTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaPlayerPlaySoundTranslator.java index 97274a723..c349c628b 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaPlayerPlaySoundTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaPlayerPlaySoundTranslator.java @@ -52,15 +52,11 @@ public class JavaPlayerPlaySoundTranslator extends PacketTranslator " - + soundMapping + (soundMapping == null ? "[not found]" : "") - + " - " + packet.toString()); String playsound; if(soundMapping == null || soundMapping.getPlaysound() == null) { // no mapping session.getConnector().getLogger() - .debug("[PlaySound] Defaulting to sound server gave us."); + .debug("[PlaySound] Defaulting to sound server gave us for " + packet.toString()); playsound = packetSound; } else { playsound = soundMapping.getPlaysound(); @@ -73,6 +69,5 @@ public class JavaPlayerPlaySoundTranslator extends PacketTranslator " + playSoundPacket); } }