Skip to content

Commit

Permalink
JavaEntityMetadataTranslator: replace stack trace with concise warning (
Browse files Browse the repository at this point in the history
GeyserMC#1086)

* JavaEntityMetadataTranslator: replace stack trace with concise warning

Removes the stack trace given when a ClassCastException occurs and replaces it with a friendlier message. Class cast errors will happen since some servers send incorrect values, and apparently it is default Minecraft behavior to ignore them.

* Update languages submodule
  • Loading branch information
Camotoy authored Aug 3, 2020
1 parent 86f18c9 commit 11c713d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.ServerEntityMetadataPacket;
import org.geysermc.connector.utils.LanguageUtils;

@Translator(packet = ServerEntityMetadataPacket.class)
public class JavaEntityMetadataTranslator extends PacketTranslator<ServerEntityMetadataPacket> {
Expand All @@ -45,7 +46,18 @@ public void translate(ServerEntityMetadataPacket packet, GeyserSession session)
if (entity == null) return;

for (EntityMetadata metadata : packet.getMetadata()) {
entity.updateBedrockMetadata(metadata, session);
try {
entity.updateBedrockMetadata(metadata, session);
} catch (ClassCastException e) {
// Class cast exceptions are really the only ones we're going to get in normal gameplay
// Because some entity rewriters forget about some values
// Any other errors are actual bugs
session.getConnector().getLogger().warning(LanguageUtils.getLocaleStringLog("geyser.network.translator.metadata.failed", metadata, entity.getEntityType()));
session.getConnector().getLogger().debug("Entity Java ID: " + entity.getEntityId() + ", Geyser ID: " + entity.getGeyserId());
if (session.getConnector().getConfig().isDebugMode()) {
e.printStackTrace();
}
}
}

entity.updateBedrockMetadata(session);
Expand Down

0 comments on commit 11c713d

Please sign in to comment.