forked from GeyserMC/Geyser
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
This commit is contained in:
parent
714c450291
commit
22a1073e54
3 changed files with 12 additions and 11 deletions
|
@ -28,6 +28,8 @@ package org.geysermc.connector.network.translators;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
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.GeyserConnector;
|
||||||
import org.geysermc.connector.network.session.GeyserSession;
|
import org.geysermc.connector.network.session.GeyserSession;
|
||||||
|
|
||||||
|
@ -40,6 +42,12 @@ public class Registry<T> {
|
||||||
public static final Registry<Packet> JAVA = new Registry<>();
|
public static final Registry<Packet> JAVA = new Registry<>();
|
||||||
public static final Registry<BedrockPacket> BEDROCK = new Registry<>();
|
public static final Registry<BedrockPacket> BEDROCK = new Registry<>();
|
||||||
|
|
||||||
|
private static final ObjectArrayList<Class<?>> IGNORED_PACKETS = new ObjectArrayList<>();
|
||||||
|
|
||||||
|
static {
|
||||||
|
IGNORED_PACKETS.add(ServerUpdateLightPacket.class);
|
||||||
|
}
|
||||||
|
|
||||||
public static void registerJava(Class<? extends Packet> targetPacket, PacketTranslator<? extends Packet> translator) {
|
public static void registerJava(Class<? extends Packet> targetPacket, PacketTranslator<? extends Packet> translator) {
|
||||||
JAVA.MAP.put(targetPacket, translator);
|
JAVA.MAP.put(targetPacket, translator);
|
||||||
}
|
}
|
||||||
|
@ -56,6 +64,7 @@ public class Registry<T> {
|
||||||
((PacketTranslator<P>) MAP.get(clazz)).translate(packet, session);
|
((PacketTranslator<P>) MAP.get(clazz)).translate(packet, session);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
if (!IGNORED_PACKETS.contains(clazz))
|
||||||
GeyserConnector.getInstance().getLogger().debug("Could not find packet for " + (packet.toString().length() > 25 ? packet.getClass().getSimpleName() : packet));
|
GeyserConnector.getInstance().getLogger().debug("Could not find packet for " + (packet.toString().length() > 25 ? packet.getClass().getSimpleName() : packet));
|
||||||
}
|
}
|
||||||
} catch (Throwable ex) {
|
} catch (Throwable ex) {
|
||||||
|
|
|
@ -45,10 +45,8 @@ public class JavaPlayBuiltinSoundTranslator extends PacketTranslator<ServerPlayB
|
||||||
String packetSound = packet.getSound().getName();
|
String packetSound = packet.getSound().getName();
|
||||||
|
|
||||||
SoundUtils.SoundMapping soundMapping = SoundUtils.fromJava(packetSound);
|
SoundUtils.SoundMapping soundMapping = SoundUtils.fromJava(packetSound);
|
||||||
session.getConnector().getLogger().debug("[Builtin] Sound mapping " + packetSound + " -> "
|
|
||||||
+ soundMapping + (soundMapping == null ? "[not found]" : "")
|
|
||||||
+ " - " + packet.toString());
|
|
||||||
if (soundMapping == null) {
|
if (soundMapping == null) {
|
||||||
|
session.getConnector().getLogger().debug("[Builtin] Sound mapping " + packetSound + " not found - " + packet.toString());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,6 +91,5 @@ public class JavaPlayBuiltinSoundTranslator extends PacketTranslator<ServerPlayB
|
||||||
soundPacket.setBabySound(false); // might need to adjust this in the future
|
soundPacket.setBabySound(false); // might need to adjust this in the future
|
||||||
soundPacket.setRelativeVolumeDisabled(false);
|
soundPacket.setRelativeVolumeDisabled(false);
|
||||||
session.sendUpstreamPacket(soundPacket);
|
session.sendUpstreamPacket(soundPacket);
|
||||||
session.getConnector().getLogger().debug("Packet sent - " + packet.toString() + " --> " + soundPacket.toString());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,15 +52,11 @@ public class JavaPlayerPlaySoundTranslator extends PacketTranslator<ServerPlaySo
|
||||||
}
|
}
|
||||||
|
|
||||||
SoundUtils.SoundMapping soundMapping = SoundUtils.fromJava(packetSound.replace("minecraft:", ""));
|
SoundUtils.SoundMapping soundMapping = SoundUtils.fromJava(packetSound.replace("minecraft:", ""));
|
||||||
session.getConnector().getLogger()
|
|
||||||
.debug("[PlaySound] Sound mapping " + packetSound + " -> "
|
|
||||||
+ soundMapping + (soundMapping == null ? "[not found]" : "")
|
|
||||||
+ " - " + packet.toString());
|
|
||||||
String playsound;
|
String playsound;
|
||||||
if(soundMapping == null || soundMapping.getPlaysound() == null) {
|
if(soundMapping == null || soundMapping.getPlaysound() == null) {
|
||||||
// no mapping
|
// no mapping
|
||||||
session.getConnector().getLogger()
|
session.getConnector().getLogger()
|
||||||
.debug("[PlaySound] Defaulting to sound server gave us.");
|
.debug("[PlaySound] Defaulting to sound server gave us for " + packet.toString());
|
||||||
playsound = packetSound;
|
playsound = packetSound;
|
||||||
} else {
|
} else {
|
||||||
playsound = soundMapping.getPlaysound();
|
playsound = soundMapping.getPlaysound();
|
||||||
|
@ -73,6 +69,5 @@ public class JavaPlayerPlaySoundTranslator extends PacketTranslator<ServerPlaySo
|
||||||
playSoundPacket.setPitch(packet.getPitch());
|
playSoundPacket.setPitch(packet.getPitch());
|
||||||
|
|
||||||
session.sendUpstreamPacket(playSoundPacket);
|
session.sendUpstreamPacket(playSoundPacket);
|
||||||
session.getConnector().getLogger().debug("[PlaySound] Packet sent - " + packet.toString() + " --> " + playSoundPacket);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue