mirror of
https://github.com/ViaVersion/ViaBackwards.git
synced 2024-11-25 12:45:35 +01:00
Implement handleTranslate() for tags in TranslatableRewriter (#734)
This commit is contained in:
parent
bd2eb42374
commit
9b8e65c59d
@ -20,9 +20,12 @@ package com.viaversion.viabackwards.api.rewriters;
|
|||||||
import com.viaversion.viabackwards.ViaBackwards;
|
import com.viaversion.viabackwards.ViaBackwards;
|
||||||
import com.viaversion.viabackwards.api.BackwardsProtocol;
|
import com.viaversion.viabackwards.api.BackwardsProtocol;
|
||||||
import com.viaversion.viabackwards.api.data.BackwardsMappingDataLoader;
|
import com.viaversion.viabackwards.api.data.BackwardsMappingDataLoader;
|
||||||
|
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
||||||
import com.viaversion.viaversion.libs.gson.JsonElement;
|
import com.viaversion.viaversion.libs.gson.JsonElement;
|
||||||
import com.viaversion.viaversion.libs.gson.JsonObject;
|
import com.viaversion.viaversion.libs.gson.JsonObject;
|
||||||
|
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||||
|
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
|
||||||
import com.viaversion.viaversion.rewriter.ComponentRewriter;
|
import com.viaversion.viaversion.rewriter.ComponentRewriter;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -67,6 +70,14 @@ public class TranslatableRewriter<C extends ClientboundPacketType> extends Compo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void handleTranslate(final UserConnection connection, final CompoundTag parentTag, final StringTag translateTag) {
|
||||||
|
final String newTranslate = mappedTranslationKey(translateTag.getValue());
|
||||||
|
if (newTranslate != null) {
|
||||||
|
parentTag.put("translate", new StringTag(newTranslate));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public @Nullable String mappedTranslationKey(final String translationKey) {
|
public @Nullable String mappedTranslationKey(final String translationKey) {
|
||||||
return translatables.get(translationKey);
|
return translatables.get(translationKey);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user