Remove usage of translation strings for code-related errors

These should never ever be seen by a normal user, and if so, developers need to see the proper error message
This commit is contained in:
Camotoy 2021-06-06 09:35:56 -04:00
parent c29a1ab3af
commit fc4f2b7890
No known key found for this signature in database
GPG key ID: 7EEFB66FE798081F
5 changed files with 16 additions and 10 deletions

View file

@ -68,10 +68,10 @@ public class PacketTranslatorRegistry<T> {
BEDROCK_TRANSLATOR.translators.put(targetPacket, translator); BEDROCK_TRANSLATOR.translators.put(targetPacket, translator);
} else { } else {
GeyserConnector.getInstance().getLogger().error(LanguageUtils.getLocaleStringLog("geyser.network.translator.invalid_target", clazz.getCanonicalName())); GeyserConnector.getInstance().getLogger().error("Class " + clazz.getCanonicalName() + " is annotated as a translator but has an invalid target packet.");
} }
} catch (InstantiationException | IllegalAccessException e) { } catch (InstantiationException | IllegalAccessException e) {
GeyserConnector.getInstance().getLogger().error(LanguageUtils.getLocaleStringLog("geyser.network.translator.failed", clazz.getCanonicalName())); GeyserConnector.getInstance().getLogger().error("Could not instantiate annotated translator " + clazz.getCanonicalName());
} }
} }

View file

@ -39,7 +39,6 @@ import org.geysermc.connector.network.session.GeyserSession;
import org.geysermc.connector.network.translators.ItemRemapper; import org.geysermc.connector.network.translators.ItemRemapper;
import org.geysermc.connector.network.translators.chat.MessageTranslator; import org.geysermc.connector.network.translators.chat.MessageTranslator;
import org.geysermc.connector.utils.FileUtils; import org.geysermc.connector.utils.FileUtils;
import org.geysermc.connector.utils.LanguageUtils;
import org.geysermc.connector.utils.LocaleUtils; import org.geysermc.connector.utils.LocaleUtils;
import org.reflections.Reflections; import org.reflections.Reflections;
@ -78,13 +77,15 @@ public abstract class ItemTranslator {
for (ItemEntry item : appliedItems) { for (ItemEntry item : appliedItems) {
ItemTranslator registered = ITEM_STACK_TRANSLATORS.get(item.getJavaId()); ItemTranslator registered = ITEM_STACK_TRANSLATORS.get(item.getJavaId());
if (registered != null) { if (registered != null) {
GeyserConnector.getInstance().getLogger().error(LanguageUtils.getLocaleStringLog("geyser.network.translator.item.already_registered", clazz.getCanonicalName(), registered.getClass().getCanonicalName(), item.getJavaIdentifier())); GeyserConnector.getInstance().getLogger().error("Could not instantiate annotated item translator " +
clazz.getCanonicalName() + ". Item translator " + registered.getClass().getCanonicalName() +
" is already registered for the item " + item.getJavaIdentifier());
continue; continue;
} }
ITEM_STACK_TRANSLATORS.put(item.getJavaId(), itemStackTranslator); ITEM_STACK_TRANSLATORS.put(item.getJavaId(), itemStackTranslator);
} }
} catch (InstantiationException | IllegalAccessException e) { } catch (InstantiationException | IllegalAccessException e) {
GeyserConnector.getInstance().getLogger().error(LanguageUtils.getLocaleStringLog("geyser.network.translator.item.failed", clazz.getCanonicalName())); GeyserConnector.getInstance().getLogger().error("Could not instantiate annotated item translator " + clazz.getCanonicalName());
} }
} }

View file

@ -151,6 +151,13 @@ public abstract class BlockTranslator {
builder.pickItem(pickItemNode.textValue()); builder.pickItem(pickItemNode.textValue());
} }
boolean waterlogged = entry.getKey().contains("waterlogged=true")
|| javaId.contains("minecraft:bubble_column") || javaId.contains("minecraft:kelp") || javaId.contains("seagrass");
if (waterlogged) {
WATERLOGGED.add(javaRuntimeId);
}
JAVA_ID_BLOCK_MAP.put(javaId, javaRuntimeId); JAVA_ID_BLOCK_MAP.put(javaId, javaRuntimeId);
BlockStateValues.storeBlockStateValues(entry.getKey(), javaRuntimeId, entry.getValue()); BlockStateValues.storeBlockStateValues(entry.getKey(), javaRuntimeId, entry.getValue());
@ -286,7 +293,6 @@ public abstract class BlockTranslator {
if (waterlogged) { if (waterlogged) {
bedrockToJavaBlockMap.putIfAbsent(bedrockRuntimeId | 1 << 31, javaRuntimeId); bedrockToJavaBlockMap.putIfAbsent(bedrockRuntimeId | 1 << 31, javaRuntimeId);
WATERLOGGED.add(javaRuntimeId);
} else { } else {
bedrockToJavaBlockMap.putIfAbsent(bedrockRuntimeId, javaRuntimeId); bedrockToJavaBlockMap.putIfAbsent(bedrockRuntimeId, javaRuntimeId);
} }

View file

@ -35,7 +35,6 @@ import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import org.geysermc.connector.GeyserConnector; import org.geysermc.connector.GeyserConnector;
import org.geysermc.connector.utils.BlockEntityUtils; import org.geysermc.connector.utils.BlockEntityUtils;
import org.geysermc.connector.utils.FileUtils; import org.geysermc.connector.utils.FileUtils;
import org.geysermc.connector.utils.LanguageUtils;
import org.reflections.Reflections; import org.reflections.Reflections;
import java.util.HashMap; import java.util.HashMap;
@ -80,7 +79,7 @@ public abstract class BlockEntityTranslator {
try { try {
BLOCK_ENTITY_TRANSLATORS.put(clazz.getAnnotation(BlockEntity.class).name(), (BlockEntityTranslator) clazz.newInstance()); BLOCK_ENTITY_TRANSLATORS.put(clazz.getAnnotation(BlockEntity.class).name(), (BlockEntityTranslator) clazz.newInstance());
} catch (InstantiationException | IllegalAccessException e) { } catch (InstantiationException | IllegalAccessException e) {
GeyserConnector.getInstance().getLogger().error(LanguageUtils.getLocaleStringLog("geyser.network.translator.block_entity.failed", clazz.getCanonicalName())); GeyserConnector.getInstance().getLogger().error("Could not instantiate annotated block entity" + clazz.getCanonicalName());
} }
} }
for (Class<?> clazz : ref.getSubTypesOf(BedrockOnlyBlockEntity.class)) { for (Class<?> clazz : ref.getSubTypesOf(BedrockOnlyBlockEntity.class)) {
@ -90,7 +89,7 @@ public abstract class BlockEntityTranslator {
BedrockOnlyBlockEntity bedrockOnlyBlockEntity = (BedrockOnlyBlockEntity) clazz.newInstance(); BedrockOnlyBlockEntity bedrockOnlyBlockEntity = (BedrockOnlyBlockEntity) clazz.newInstance();
BEDROCK_ONLY_BLOCK_ENTITIES.add(bedrockOnlyBlockEntity); BEDROCK_ONLY_BLOCK_ENTITIES.add(bedrockOnlyBlockEntity);
} catch (InstantiationException | IllegalAccessException e) { } catch (InstantiationException | IllegalAccessException e) {
GeyserConnector.getInstance().getLogger().error(LanguageUtils.getLocaleStringLog("geyser.network.translator.block_state.failed", clazz.getCanonicalName())); GeyserConnector.getInstance().getLogger().error("Could not instantiate annotated block state " + clazz.getCanonicalName());
} }
} }
} }

@ -1 +1 @@
Subproject commit e1e8fd6c2b8abf366e60085c23a55a2c943806ae Subproject commit bf4bf0554bd9705f33fe4ccf4aab0ec0075350d4