Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-09-08 20:43:04 +02:00
Enable debug property in Log4J config if applicable (#1906)
With this commit, debug messages in Netty and Protocol will now show if debug mode is enabled in the Geyser standalone config. There is also some small tuning to the PacketTranslatorRegistry for cleanliness and maybe some minor performance.
Dieser Commit ist enthalten in:
Ursprung
3140d3ced7
Commit
1ec589fa35
@ -32,6 +32,7 @@ import com.fasterxml.jackson.databind.introspect.AnnotatedField;
|
|||||||
import com.fasterxml.jackson.databind.introspect.BeanPropertyDefinition;
|
import com.fasterxml.jackson.databind.introspect.BeanPropertyDefinition;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import net.minecrell.terminalconsole.TerminalConsoleAppender;
|
import net.minecrell.terminalconsole.TerminalConsoleAppender;
|
||||||
|
import org.apache.logging.log4j.Level;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.core.Appender;
|
import org.apache.logging.log4j.core.Appender;
|
||||||
import org.apache.logging.log4j.core.Logger;
|
import org.apache.logging.log4j.core.Logger;
|
||||||
@ -167,11 +168,6 @@ public class GeyserStandaloneBootstrap implements GeyserBootstrap {
|
|||||||
this.onEnable();
|
this.onEnable();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onEnable(boolean useGui) {
|
|
||||||
this.useGui = useGui;
|
|
||||||
this.onEnable();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
Logger logger = (Logger) LogManager.getRootLogger();
|
Logger logger = (Logger) LogManager.getRootLogger();
|
||||||
@ -213,6 +209,9 @@ public class GeyserStandaloneBootstrap implements GeyserBootstrap {
|
|||||||
}
|
}
|
||||||
GeyserConfiguration.checkGeyserConfiguration(geyserConfig, geyserLogger);
|
GeyserConfiguration.checkGeyserConfiguration(geyserConfig, geyserLogger);
|
||||||
|
|
||||||
|
// Allow libraries like Protocol to have their debug information passthrough
|
||||||
|
logger.get().setLevel(geyserConfig.isDebugMode() ? Level.DEBUG : Level.INFO);
|
||||||
|
|
||||||
connector = GeyserConnector.start(PlatformType.STANDALONE, this);
|
connector = GeyserConnector.start(PlatformType.STANDALONE, this);
|
||||||
geyserCommandManager = new GeyserCommandManager(connector);
|
geyserCommandManager = new GeyserCommandManager(connector);
|
||||||
|
|
||||||
|
@ -30,6 +30,7 @@ import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerUpdate
|
|||||||
import com.github.steveice10.packetlib.packet.Packet;
|
import com.github.steveice10.packetlib.packet.Packet;
|
||||||
import com.nukkitx.protocol.bedrock.BedrockPacket;
|
import com.nukkitx.protocol.bedrock.BedrockPacket;
|
||||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||||
|
import org.geysermc.common.PlatformType;
|
||||||
import org.geysermc.connector.GeyserConnector;
|
import org.geysermc.connector.GeyserConnector;
|
||||||
import org.geysermc.connector.network.session.GeyserSession;
|
import org.geysermc.connector.network.session.GeyserSession;
|
||||||
import org.geysermc.connector.utils.FileUtils;
|
import org.geysermc.connector.utils.FileUtils;
|
||||||
@ -89,12 +90,15 @@ public class PacketTranslatorRegistry<T> {
|
|||||||
public <P extends T> boolean translate(Class<? extends P> clazz, P packet, GeyserSession session) {
|
public <P extends T> boolean translate(Class<? extends P> clazz, P packet, GeyserSession session) {
|
||||||
if (!session.getUpstream().isClosed() && !session.isClosed()) {
|
if (!session.getUpstream().isClosed() && !session.isClosed()) {
|
||||||
try {
|
try {
|
||||||
if (translators.containsKey(clazz)) {
|
PacketTranslator<P> translator = (PacketTranslator<P>) translators.get(clazz);
|
||||||
((PacketTranslator<P>) translators.get(clazz)).translate(packet, session);
|
if (translator != null) {
|
||||||
|
translator.translate(packet, session);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
if (!IGNORED_PACKETS.contains(clazz))
|
if ((GeyserConnector.getInstance().getPlatformType() != PlatformType.STANDALONE || !(packet instanceof BedrockPacket)) && !IGNORED_PACKETS.contains(clazz)) {
|
||||||
|
// Other debug logs already take care of Bedrock packets for us if on standalone
|
||||||
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) {
|
||||||
GeyserConnector.getInstance().getLogger().error(LanguageUtils.getLocaleStringLog("geyser.network.translator.packet.failed", packet.getClass().getSimpleName()), ex);
|
GeyserConnector.getInstance().getLogger().error(LanguageUtils.getLocaleStringLog("geyser.network.translator.packet.failed", packet.getClass().getSimpleName()), ex);
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren